我有一个自定义EditAppointment
表单,其中包含3组“开始”和“结束”字段。
“计划”部分中的“开始”和“结束”字段是Scheduler
映射中绑定到“开始”和“结束”的默认约会字段。
已发布和实际下的开始和结束字段是只读的,与规划(DevExpress.XtraEditors.DateEdit
和DevExpress.XtraEditors.TimeEdit
)下的字段类型相同,但获取并将其值保存到{{1}映射在CustomFields
映射中。
自定义字段定义为“属性”:
Scheduler
我更改了Planning下的开始日期和结束日期,直到事情在时间轴上排成一行,然后我点击了 Publish ,它将数据从计划发布到发布:
Public Class MyAppointmentFormController
Inherits AppointmentFormController
...
Public Property CustomPublishedStartDateTime() As DateTime
Get
Return CDate(EditedAppointmentCopy.CustomFields("PublishedStartDateTime"))
End Get
Set(ByVal value As DateTime)
EditedAppointmentCopy.CustomFields("PublishedStartDateTime") = value
End Set
End Property
Public Property CustomPublishedCompletedDateTime() As DateTime
Get
Return CDate(EditedAppointmentCopy.CustomFields("PublishedCompletedDateTime"))
End Get
Set(ByVal value As DateTime)
EditedAppointmentCopy.CustomFields("PublishedCompletedDateTime") = value
End Set
End Property
...
End Class
然后我点击确定:
' Copies Planned data to Published
Private Sub btnPublishJob_Click(sender As Object, e As EventArgs) Handles btnPublishJob.Click
txtCustomPublishedPackagingLine.Text = AppointmentResourceEdit1.Text
txtCustomPublishedRunRatePerShift.Text = txtCustomPlanningRunRatePerShift.Text
dtPublishedStart.EditValue = dtPlanningStart.EditValue
timePublishedStart.EditValue = New DateTime(timePlanningStart.Time.TimeOfDay.Ticks)
dtPublishedEnd.EditValue = dtPlanningEnd.EditValue
timePublishedEnd.EditValue = New DateTime(timePlanningEnd.Time.TimeOfDay.Ticks)
txtCustomPublishedTotalUnits.Text = txtCustomPlannedTotalUnits.Text
End Sub
当代码到达Private Sub btnOK_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOK.Click
' Required to check the appointment for conflicts.
If (Not controller.IsConflictResolved()) Then
Return
End If
' Save Planning
controller.DisplayStart = Me.dtPlanningStart.DateTime.Date + Me.timePlanningStart.Time.TimeOfDay
controller.DisplayEnd = Me.dtPlanningEnd.DateTime.Date + Me.timePlanningEnd.Time.TimeOfDay
controller.CustomPlannedRunRatePerShift = txtCustomPlanningRunRatePerShift.Text
' Save Published
controller.CustomPublishedStartDateTime = Me.dtPublishedStart.DateTime.Date + Me.timePublishedStart.Time.TimeOfDay
controller.CustomPublishedCompletedDateTime = Me.dtPublishedEnd.DateTime.Date + Me.timePublishedEnd.Time.TimeOfDay
controller.CustomPublishedPackagingLine = txtCustomPublishedPackagingLine.Text
controller.CustomPublishedRunRatePerShift = txtCustomPublishedRunRatePerShift.Text
controller.Description = rtbCustomJobNotes.Text
Try
' Save all changes of the editing appointment.
controller.ApplyChanges()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
时,我收到以下错误:
发生了FormatException
输入刺痛的格式不正确。
故障排除提示:
将字符串转换为DateTime时,解析字符串以获取 将每个变量放入DateTime对象之前的日期。
...
我已经尝试controller.ApplyChanges()
,DateTime.Parse
,DateTime.ParseExact
,Date.Parse
,首先分配日期,然后添加时间,还有很多其他内容,但我只是无法超越这个。
如何将自定义Date.ParseExact
表单中的日期保存回sql数据库。我真的希望使用自定义约会属性来简化它。
我只担心已公布的开始和结束日期和时间。