This is a sense the continue of this question. But for be accurate I explain what I want to do. I've developed a web application that allow the user to manage the working days (I call it working plan), now I'm current developing a client application for synch the local data on the web database. So I must have the full compatibility with all data information from the client to the web. The bottom code simply create a workingPlan
for a specific user, this workingPlan is in JsonFormat
, the result's that I want achieve is like this:
"monday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
"tuesday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
How you can see each day have the start
and the end
working time. Also, in each day, I can have multiple breaks, this is for split the working slot. Now the json encoded on the top is a string generated from PHP, while the json generated in vb.net
is the result of DateTimePicker
filled. Essentially what I need to do is valorize the breaks, now I add the breaks in a DataGrid
, for example:
The final json format will be (for this specific case):
{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"19:30","end":"19:50"},{"start":"21:40","end":"21:30"}]},"tuesday":{"start":null,"end":null,"breaks":[{"start":null,"end":null},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"19:37","end":"19:50"}...
The class for manage the Week
, Breaks
Day
are so declared:
Public Class WorkDay
<JsonProperty("start")>
Public Property starttime As String
<JsonProperty("end")>
Public Property endtime As String
Public Property breaks As Break()
End Class
Public Class Break
<JsonProperty("start")>
Public Property starttime As String
<JsonProperty("end")>
Public Property endtime As String
End Class
Public Class WorkWeek
Public Property monday As WorkDay
Public Property tuesday As WorkDay
Public Property wednesday As WorkDay
Public Property thursday As WorkDay
Public Property friday As WorkDay
Public Property saturday As WorkDay
Public Property sunday As WorkDay
Public Sub New()
monday = New WorkDay
tuesday = New WorkDay
wednesday = New WorkDay
thursday = New WorkDay
friday = New WorkDay
saturday = New WorkDay
sunday = New WorkDay
End Sub
End Class
Now, for valorize the breaks of each day I iterate on this DataGrid
For Each row As DataGridViewRow In User.break_view.Rows
If Not row.IsNewRow Then
If row.Cells(0).Value.ToString = "Monday" Then
workWeek.monday.breaks = row.Cells(1).Value.ToString 'Incriminated line
End If
... each day condition
End If
Next
on this workWeek.monday.breaks = row.Cells(1).Value.ToString
line I get this error:
Can't convert String into Users.Break()
also I want to know if there's a way to optimize it, 'cause actually I must perform 7 condition and check if the current day in iteration is Monday or Tuesday etc... and so add the break to this specific day. If I was unclear on something that I explained, please tell me and I'll try to provider more and specific details. Thanks for the attention.