Hello,
can someone help me how i can make to Update & Delete records from flowlayoutpanel to database.
I have button Done, when i press it i need to update all results that were showed in flowlayoutpanel.
Example:
In flowlayoutpanel i have 7 results, some of them will be marked as checked already from database that has status "Completed"
1. Textsadasd
2. asdsada
3. ahaha
4. Hahah - Already Checked
5.Ttgg - Already Checked
6. Yyyty
7. Weee
So i want first when i click the button to say to me "Hey wait first you need to select some tasks checkbox before proceed", then if i select 1 or 4 checkboxes at same time and then click button Done, to update the database and set for all marked with checked status inside database with status Completed.
I have made simple source project Simple Project Download
Please help me
Public Function FindTasksUser() As DataTable
Using cons As New SQLiteConnection(ServerStatus)
Using cmd As New SQLiteCommand()
cmd.Connection = cons
cmd.CommandText = "SELECT * FROM Tasks WHERE accountName = @GetUser ORDER BY [ID] ASC;"
cmd.Parameters.AddWithValue("@GetUser", UserUserAcc).ToString()
cons.Open()
Using sda As New SQLiteDataAdapter(cmd)
Dim dt As New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
End Using
End Function
Private Sub GenerateTasksUser()
FlowLayoutPanel3.Controls.Clear()
Dim dt As DataTable = New ClassBLL().GetTasksUser()
If dt IsNot Nothing Then
If dt.Rows.Count > 0 Then
Dim listItems As UserTasks() = New UserTasks(dt.Rows.Count - 1) {}
For i As Integer = 0 To 1 - 1
For Each row As DataRow In dt.Rows
Dim listItem As New UserTasks()
listItems(i) = listItem
listItems(i).TaskTitle = row("taskstitle").ToString()
listItems(i).TaskSubject = row("tasksubject").ToString()
listItems(i).TaskFrom = row("taskfromname").ToString()
FlowLayoutPanel3.Controls.Add(listItems(i))
Next
Next
End If
End If
End Sub
Private Sub Guna2ImageButton1_Click(sender As Object, e As EventArgs) Handles Guna2ImageButton1.Click
MainCP.FlowLayoutPanel3.Controls.RemoveByKey(Me.Name)
'or Directly to use Dispose
Dispose()
'or another option
Parent.Controls.Remove(Me)
'or another option i think is:
For Each control As Control In MainCP.FlowLayoutPanel3.Controls
MainCP.FlowLayoutPanel3.Controls.Remove(control)
control.Dispose()
Next
End Sub
Public Class UserTasks
Public _taskTitle As String
Public _taskSubject As String
Public _taskFrom As String
Public _CheckBoxText As String
Public _checked As Boolean = True
Public Property TaskTitle As String
Get
Return _taskTitle
End Get
Set(value As String)
_taskTitle = value
Label1.Text = value
End Set
End Property
Public Property TaskSubject As String
Get
Return _taskSubject
End Get
Set(value As String)
_taskSubject = value
Label2.Text = value
End Set
End Property
Public Property TaskFrom As String
Get
Return _taskFrom
End Get
Set(value As String)
_taskFrom = value
Label3.Text = value
End Set
End Property
Public Property CheckBoxText As String
Get
Return _CheckBoxText
End Get
Set(value As String)
_CheckBoxText = value
'CheckBox1.Checked = value
End Set
End Property
Public Property CheckBoxCheck As Boolean
Get
Return _checked
End Get
Set(value As Boolean)
_checked = value
CheckBox1.Checked = value
End Set
End Property
Private Sub UserTasks_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class