its first time form to use ext.net calendar. i have dates in sql database.
i try to bind calendarpanel with eventstore as dynamicly. but come blank calendar.
***Public Sub Calendar_Fill()
Sql = "select distinct [SrvSchDate],[SrvWave],[SrvMvGrp]from Migrate_info where [SrvSchDate] > CURRENT_TIMESTAMP group by [SrvSchDate],[SrvWave],[SrvMvGrp]"
getdata(Sql)
Dim oEvents = New Ext.Net.EventCollection
Dim oEvtStore = New Ext.Net.EventStore
Dim oEvt As Ext.Net.Event
Dim j As Integer = 0
For Each row As DataRow In ds.Tables(0).Rows
oEvt = New Ext.Net.Event
oEvt.CalendarId = j
oEvt.EventId = j
oEvt.EndDate = ds.Tables(0).Rows(j).Item(0)
oEvt.StartDate = ds.Tables(0).Rows(j).Item(0)
oEvt.Title = ds.Tables(0).Rows(j).Item(1) + " " + ds.Tables(0).Rows(j).Item(2)
j = j + 1
oEvents.Add(oEvt)
Next
oEvtStore.Events.AddRange(oEvents)
myCalendar.EventStore = oEvtStore
End Sub`
*** client side
</Groups>
</GroupStore>
<MonthView ID="MonthView1"
runat="server"
ShowHeader="true"
ShowWeekLinks="true"
ShowWeekNumbers="true"
/>
</ext:CalendarPanel>
** server side**
Public Sub Calendar_Fill()
Sql = "select distinct [SrvSchDate],[SrvWave],[SrvMvGrp]from Migrate_info where [SrvSchDate] > CURRENT_TIMESTAMP group by [SrvSchDate],[SrvWave],[SrvMvGrp]"
getdata(Sql)
Dim oEvents = New Ext.Net.EventCollection
Dim oEvtStore = New Ext.Net.EventStore
Dim oEvt As Ext.Net.Event
Dim j As Integer = 0
For Each row As DataRow In ds.Tables(0).Rows
oEvt = New Ext.Net.Event
oEvt.CalendarId = j
oEvt.EventId = j
oEvt.EndDate = CDate(ds.Tables(0).Rows(j).Item(0))
oEvt.StartDate = CDate(ds.Tables(0).Rows(j).Item(0))
oEvt.Title = ds.Tables(0).Rows(j).Item(1) + " " + ds.Tables(0).Rows(j).Item(2)
j = j + 1
oEvents.Add(oEvt)
Next
oEvtStore.Events.AddRange(oEvents)
myCalendar.EventStore = oEvtStore
End Sub
Related
Dim command As New SqlCommand("SELECT * From tblUserInfo WHERE Username='" & Trim(frmdashboard.ToolStripLabel4.Text) & "'", con)
Dim table As New DataTable()
Dim sqlAdapter As New SqlDataAdapter(command)
sqlAdapter.Fill(table)
Me.UserTypeTextBox.Text = table.Rows(0)(10).ToString()
Me.UsernameTextBox.Text = table.Rows(0)(9).ToString()
Me.Email_AddressTextBox.Text = table.Rows(0)(12).ToString()
Me.PositionTextBox.Text = table.Rows(0)(1).ToString()
Me.NameTextBox.Text = table.Rows(0)(2).ToString()
Me.AddressTextBox.Text = table.Rows(0)(3).ToString()
Me.Date_of_BirthDateTimePicker.Value = table.Rows(0)(4).ToString()
Me.AgeTextBox.Text = table.Rows(0)(5).ToString()
Me.SexComboBox.Text = table.Rows(0)(6).ToString()
Me.Telephone_NumberTextBox.Text = table.Rows(0)(7).ToString()
Me.Mobile_NumberTextBox.Text = table.Rows(0)(8).ToString()
Me.Security_Question_1TextBox.Text = table.Rows(0)(13).ToString()
Me.Security_Question_2TextBox.Text = table.Rows(0)(15).ToString()
Dim img() As Byte
img = table.Rows(0)(17)
Dim ms As New MemoryStream(img)
Me.PicturePictureBox.Image = Image.FromStream(ms)
This should retrieve the data of a specific person. The error I get is
System.IndexOutOfRangeException: There is no row at position 0
You are assuming that your query will return at least one record which might/might not be true all times. You should first check if your tables has at least one row as below:
if ( table.Rows != null && tables.Rows.Count > 0)
{
Dim img() As Byte;
img = table.Rows(0)(17)
Dim ms As New MemoryStream(img)
Me.PicturePictureBox.Image = Image.FromStream(ms)
}
I am doing my homework but stuck on a part. Problem is, How can i populate seat number in array of controls(labels) using database. I already created labels and a class to retrieve all rows from database but how can i apply it in main form and populate labels.
--------------------------Class---------------------------------------
Public Shared Function getOneRow(PK As Integer) As datMovieTimes
Dim returnRow As New datMovieTimes(0)
Dim connDB As New SqlConnection
connDB.ConnectionString = Conn.getConnectionString
Dim command As New SqlCommand
command.Connection = connDB
command.CommandType = CommandType.Text
command.CommandText = SQLStatements.SELECT_1_BY_ID
command.Parameters.AddWithValue("#Key", PK)
Try
connDB.Open()
Dim dR As IDataReader = command.ExecuteReader
If dR.Read() Then
returnRow.showingID = PK
If Not IsDBNull(dR(Fields.movieID)) Then returnRow.movieID = dR(Fields.movieID)
If Not IsDBNull(dR(Fields.dateTime)) Then returnRow.dateTime = dR(Fields.dateTime)
If Not IsDBNull(dR(Fields.isActive)) Then returnRow.isActive = dR(Fields.isActive)
End If
Catch ex As Exception
Console.WriteLine(Err.Description)
End Try
Return returnRow
End Function
Public Shared Function getAllRows() As Generic.List(Of datMovieTimes)
Dim returnRows As New Generic.List(Of datMovieTimes)
Dim connDB As New SqlConnection
connDB.ConnectionString = Conn.getConnectionString
Dim command As New SqlCommand
command.Connection = connDB
command.CommandType = CommandType.Text
command.CommandText = SQLStatements.SELECT_ALL
Try
connDB.Open()
Dim dR As IDataReader = command.ExecuteReader
Do While dR.Read()
Dim Row As New datMovieTimes(0)
If Not IsDBNull(dR(Fields.showingID)) Then Row.showingID = dR(Fields.showingID)
If Not IsDBNull(dR(Fields.movieID)) Then Row.movieID = dR(Fields.movieID)
If Not IsDBNull(dR(Fields.dateTime)) Then Row.dateTime = dR(Fields.dateTime)
If Not IsDBNull(dR(Fields.isActive)) Then Row.isActive = dR(Fields.isActive)
returnRows.Add(Row)
Loop
Catch ex As Exception
Console.WriteLine(Err.Description)
End Try
Return returnRows
End Function
-----------------------------main form-----------------------------------------
Public Sub createSeat()
Dim S1 As Label
For X As Integer = 1 To _MAX_X
For Y As Integer = 1 To _MAX_Y
S1 = New Label
S1.Height = 25
S1.Width = 25
S1.BackColor = Color.LightGreen
S1.Top = 100 + (X - 1) * (S1.Height + 5)
S1.Left = 200 + (Y - 1) * (S1.Width + 5)
S1.TextAlign = ContentAlignment.MiddleCenter
S1.Text = Y.ToString
AddHandler S1.Click, AddressOf GenericLabel_Click
Me.Controls.Add(S1)
_SeatArray(X, Y) = S1
Next
Next
For X As Integer = 0 To 9
_AlphaLabel(X) = New Label
_AlphaLabel(X).Height = 25
_AlphaLabel(X).Width = 25
_AlphaLabel(X).BackColor = Color.Transparent
_AlphaLabel(X).Top = 130 + (X - 1) * (_AlphaLabel(X).Height + 6)
_AlphaLabel(X).Left = 170
_AlphaLabel(X).Text = _AlphaName(X)
Me.Controls.Add(_AlphaLabel(X))
Next
End Sub
Private Sub GenericLabel_Click(sender As Object, e As EventArgs)
Dim L As New Label
L = DirectCast(sender, Label)
If L.BackColor = Color.LightGreen Then
L.BackColor = Color.Orange
clickLess -= 1
ElseIf L.BackColor = Color.Orange Then
L.BackColor = Color.LightGreen
clickLess += 1
End If
clickCount += 1
Me.lblRemainingCount.Text = clickLess.ToString
Me.nudTicketsCount.Value = clickCount
If clickLess <= 0 Then
MsgBox("No more seats left.", MsgBoxStyle.OkOnly, "House Full")
End If
End Sub
Database pic
When creating labels, insert one more line:
S1.Name = "MyLabel" & X & Y
When accessing the label:
Dim MyCurrentLabel as Label
MyCurrentLabel = CType("MyLabel" & X & Y, Label)
Then you can do things with the current label:
MyCurrentLabel.Text = "Hello World"
current image
Now it is something like this, so it want to change the colour to red if it is paid according to database.
Thanks
I found the answer, sorry i forgot to mention it because i was busy in completing the project
----------------------Seat creation----------------------------------------
Public Sub createSeat()
Dim S1 As Label
Dim numValue As Integer = 1
For X As Integer = 1 To _MAX_X
For Y As Integer = 1 To _MAX_Y
S1 = New Label
S1.Height = 25
S1.Width = 25
S1.BackColor = Color.LightGreen
S1.Top = 180 + (X - 1) * (S1.Height + 5)
S1.Left = 200 + (Y - 1) * (S1.Width + 5)
S1.TextAlign = ContentAlignment.MiddleCenter
S1.Text = Y.ToString
' S1.Text = numValue
S1.Name = "Label" & numValue
AddHandler S1.Click, AddressOf GenericLabel_Click
Me.Controls.Add(S1)
_SeatArray(X, Y) = S1
numValue += 1
Next
Next
For X As Integer = 0 To 9
_AlphaLabel(X) = New Label
_AlphaLabel(X).Height = 25
_AlphaLabel(X).Width = 25
_AlphaLabel(X).BackColor = Color.Transparent
_AlphaLabel(X).Top = 210 + (X - 1) * (_AlphaLabel(X).Height + 6)
_AlphaLabel(X).Left = 170
_AlphaLabel(X).Text = _AlphaName(X)
Me.Controls.Add(_AlphaLabel(X))
Next
End Sub
-------------------------------populate seat number----------------------------------
Public Sub populateSeatNumber()
Dim connectionString As String = DBL.Conn.getConnectionString
Dim connection As New SqlConnection(connectionString)
connection.Open()
Dim selectStatement As String = "SELECT * FROM datTicketsSold"
Dim selectCommand As New SqlCommand(selectStatement, connection)
Dim daSoldTickets As New SqlDataAdapter(selectCommand)
Dim dsSoldTickets As DataSet = New DataSet
daSoldTickets.Fill(dsSoldTickets, "datTicketsSold")
connection.Close()
Dim dtTickets As DataTable = dsSoldTickets.Tables("datTicketsSold")
Dim row As DataRow
For Each row In dtTickets.Rows
If row(3) = True Then
CType(Controls("Label" & row(2)), Label).BackColor = Color.Red
redCounter += 1
Else
CType(Controls("Label" & row(2)), Label).BackColor = Color.Yellow
yellowCounter += 1
End If
Next
Me.lblReservedCount.Text = yellowCounter.ToString
Me.lblSoldCount.Text = redCounter.ToString
End Sub
Thanks everyone
How can I write an equivalent SQL script in T-SQL?
I've written this code in MS Access to edit records - how can I do the same thing in SQL Server?
For each combination of J_CaseNum and J_Index J_PersonIndex needs to be incremented. There can be anywhere from 1 to 50 person for a given combination.
Dim rs As Recordset
Dim rs1 As Recordset
Dim i As Long
Dim s As String
sql = "Select J_CaseNum, J_Index, J_VehicleIndex, J_PersonIndex, J_CaseNo, J_PersonID, Ind_Last_NM from dbo_DCIPS Order By J_CaseNum, J_Index, Ind_Last_NM"
Set rs = CurrentDb.OpenRecordset(sql)
Set rs1 = CurrentDb.OpenRecordset(sql)
rs.MoveLast
cnt = rs.RecordCount
rs.MoveFirst
i = 0
SysCmd acSysCmdInitMeter, "_", cnt
While Not rs.EOF
If i = 0 Then
rs.Edit
rs!J_PersonIndex = "01"
rs!J_CaseNo = rs!J_CaseNum & rs!J_Index
rs!J_PersonID = rs!J_CaseNo & rs!J_VehicleIndex & rs!J_PersonIndex
rs.Update
j = 1
i = 1
rs.MoveNext
Else
If (rs1!J_CaseNum = rs!J_CaseNum) And (rs1!J_Index = rs!J_Index) Then
j = j + 1
s = j
rs.Edit
rs!J_PersonIndex = Right("00" + s, 2)
rs!J_CaseNo = rs!J_CaseNum & rs!J_Index
rs!J_PersonID = rs!J_CaseNo & rs!J_VehicleIndex & rs!J_PersonIndex
rs.Update
rs.MoveNext
rs1.MoveNext
Else
j = 1
s = j
rs.Edit
rs!J_PersonIndex = Right("00" + s, 2)
rs!J_CaseNo = rs!J_CaseNum & rs!J_Index
rs!J_PersonID = rs!J_CaseNo & rs!J_VehicleIndex & rs!J_PersonIndex
rs.Update
rs.MoveNext
rs1.MoveNext
End If
End If
i = i + 1
SysCmd acSysCmdUpdateMeter, i
If (i Mod 1000) = 0 Then Stop
Wend
Thanks in advance
ok so you want a counter in each group of case/index/person. I would do something like this to get a unique person id.
SELECT ROW_NUMBER() OVER (partition BY caseNum,[index] order by [index])
AS personId , caseNum, [index], personName FROM table
And then you can use this dataset to insert into a new table or update existing table from this query (which is a modified command)
In an older WinForms app this worked, but in WPF it will move the item only once, the only current workaround is the save it to the back end DB, open again and move one more space. The list items are supplied by a DataTable
Private Sub Reports_BalanceSheet_ListBoxMoveUp(LB As ListBox, DT As DataTable, DisplayName As String, Optional MasterListBox As ListBox = Nothing)
Try
Dim StartIndex As Integer = LB.SelectedIndex
Dim CatID As Integer = 0
'Update the datasource
Dim SR() As DataRow
If DisplayName = "Name" Then
SR = DT.Select("ID > 0 AND FormID = " & Form_ID, Nothing)
Else
CatID = MasterListBox.SelectedValue
'Check that the positions are correct
If DataChanged = False Then
Dim vRowID As Integer = 0
For Each Row As DataRow In DT.Rows
If Row("FormID") = Form_ID And Row("CatID") = CatID Then
Row("Position") = vRowID
vRowID += 1
End If
Next
End If
SR = DT.Select("ID > 0 AND FormID = " & Form_ID & " AND CatID = " & CatID, "Position")
End If
Dim vString As String = ""
Dim vUpperID As Integer = 0
Dim vCurrentID As Integer = 0
For Each Row As DataRow In SR
Dim vPos As Integer = Row("Position")
If vPos = StartIndex - 1 Then
vUpperID = Row("ID")
End If
If vPos = StartIndex Then
vCurrentID = Row("ID")
End If
Next
If Not vUpperID = 0 And Not vCurrentID = 0 Then
DT.Select("ID = " & vUpperID)(0)("Position") = StartIndex
DT.Select("ID = " & vCurrentID)(0)("Position") = StartIndex - 1
If DisplayName = "Name" Then
DT.DefaultView.RowFilter = "FormID = " & Form_ID
Else
DT.DefaultView.RowFilter = "FormID = " & Form_ID & " AND CatID = " & CatID
End If
DT.DefaultView.Sort = "Position"
DT = DT.DefaultView.ToTable
DT.AcceptChanges()
With LB
.SelectedValuePath = "ID"
.DisplayMemberPath = DisplayName
.ItemsSource = DT.DefaultView
.SelectedValue = vCurrentID
.UpdateLayout()
End With
End If
Catch ex As Exception
EmailError(ex)
End Try
End Sub
Got it working this way (and with less code) :-)
Dim StartIndex As Integer = LB.SelectedIndex
Dim vTotalRows As Integer = DT.Rows.Count - 1
If Not StartIndex = vTotalRows Then
Dim vSelected As DataRow = DT.Rows(StartIndex)
Dim vNew As DataRow = DT.NewRow()
vNew.ItemArray = vSelected.ItemArray
DT.Rows.Remove(vSelected)
DT.Rows.InsertAt(vNew, StartIndex + 1)
LB.SelectedIndex = StartIndex + 1
Dim vPos As Integer = 0
For Each Row As DataRow In DT.Rows
Row("Position") = vPos
vPos += 1
Next
End If
I want to run the fetching of a Database into a background worker but it seems to be crashing without Visual Studio returning me an error in my code.
Here's the code in the DoWork:
Private Sub ITSM_Fetch_BW_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles ITSM_Fetch_BW.DoWork
Dim sql As String = "xxxx"
Dim ConnString As String = "DRIVER={AR System ODBC Driver};ARServer=xxxx;ARServerPort=xxxx;ARPrivateRpcSocket=xxxx;UID=xxxx;PWD=xxxx;ARAuthentication=;ARUseUnderscores=1;SERVER=NotTheServer"
Dim connection As New Odbc.OdbcConnection(ConnString)
connection.Open()
Dim ODBC_Command As New Odbc.OdbcCommand(sql, connection)
Dim ODBC_reader As Odbc.OdbcDataReader
'Load the Data into the local Memory
ODBC_reader = ODBC_Command.ExecuteReader
e.Result = ODBC_reader
ODBC_reader.Close()
End Sub
Private Sub ITSM_Fetch_BW_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles ITSM_Fetch_BW.RunWorkerCompleted
Data = New DataTable
Data.Load(e.Result)
Dim Count_ToDo(5) As String
Count_ToDo(0) = "Product_Name"
Count_ToDo(1) = "Status"
Count_ToDo(2) = "Language"
Count_ToDo(3) = "Assigned_Group"
Count_ToDo(4) = "Priority"
Count_ToDo(5) = "Company"
For Each Item As String In Count_ToDo
Dim i As Integer = 0
Dim ITEM_Count(0, 1) As String
For Each Ticket As DataRow In Data.Rows
'PART FOR THE CI
If IsDBNull(Ticket.Item(Item)) = False Then
Dim IsInIndex As Integer = -1
If i = 0 Then
ITEM_Count(0, 0) = Ticket.Item(Item)
ITEM_Count(0, 1) = 1
Else
For x As Integer = 0 To ITEM_Count.GetLength(0) - 1
If ITEM_Count(x, 0) = Ticket.Item(Item) Then
IsInIndex = x
End If
Next
If IsInIndex = -1 Then
Dim ITEM_Count_Temp(ITEM_Count.GetLength(0), ITEM_Count.GetLength(0)) As String
ITEM_Count_Temp = ITEM_Count
ReDim ITEM_Count(ITEM_Count.GetLength(0), 1)
For x As Integer = 0 To ITEM_Count_Temp.GetLength(0) - 1
For y As Integer = 0 To ITEM_Count_Temp.GetLength(1) - 1
ITEM_Count(x, y) = ITEM_Count_Temp(x, y)
Next
Next
ITEM_Count(ITEM_Count.GetLength(0) - 1, 0) = Ticket.Item(Item)
ITEM_Count(ITEM_Count.GetLength(0) - 1, 1) = 1
Else
ITEM_Count(IsInIndex, 1) = ITEM_Count(IsInIndex, 1) + 1
End If
End If
Else
'IF NULL
End If
i = i + 1
Next
'CI_COUNT FILLING
'ORDERING BY COUNT
Dim ITEM_obj = New List(Of obj)
Dim ITEM_ToObj As String = ""
Dim ITEMCount_ToObj As String = ""
For x As Integer = 0 To ITEM_Count.GetLength(0) - 1
ITEM_ToObj = ITEM_Count(x, 0)
ITEMCount_ToObj = ITEM_Count(x, 1)
ITEM_obj.Add(New obj(ITEM_ToObj, ITEMCount_ToObj))
Next
ITEM_obj = OrderItem(ITEM_obj)
Dim Item_Count_listview As ListViewItem
For Each Itemobj As obj In ITEM_obj
Dim Transfer_Array(2) As String
Transfer_Array(0) = Itemobj.Item
Transfer_Array(1) = Itemobj.Item_Count
Item_Count_listview = New ListViewItem(Transfer_Array)
Select Case Item
Case "Product_Name"
CI_Count_Table.Items.Add(Item_Count_listview)
Case "Status"
Status_Count_Table.Items.Add(Item_Count_listview)
Case "Language"
Language_Count_Table.Items.Add(Item_Count_listview)
Case "Assigned_Group"
AssignedGroup_Count_Table.Items.Add(Item_Count_listview)
Case "Priority"
Priority_Count_Table.Items.Add(Item_Count_listview)
Case "Company"
LOB_Count_Table.Items.Add(Item_Count_listview)
Case Else
MsgBox("No Category Of this type exist. Programming Issue. Item is: " & Item)
End Select
Next
Next
End Sub
What is not possible to run into a background worker like this?
regards,