Vb.net 问题使用自定义约会编辑表单保存自定义日期编辑和时间编辑字段
我有一个自定义的EditAppointment表单,它包含3组开始和结束字段 “计划”部分中的“开始”和“结束”字段是默认的约会字段,在计划程序映射中绑定到“开始”和“结束” “已发布”和“实际”下的“开始”和“结束”字段为只读字段,与“规划DevExpress.XtraEditors.DateEdit”和“DevExpress.XtraEditors.TimeEdit”下的字段类型相同,但获取并将其值保存到调度程序映射中映射的自定义字段 自定义字段定义为属性:Vb.net 问题使用自定义约会编辑表单保存自定义日期编辑和时间编辑字段,vb.net,winforms,devexpress,Vb.net,Winforms,Devexpress,我有一个自定义的EditAppointment表单,它包含3组开始和结束字段 “计划”部分中的“开始”和“结束”字段是默认的约会字段,在计划程序映射中绑定到“开始”和“结束” “已发布”和“实际”下的“开始”和“结束”字段为只读字段,与“规划DevExpress.XtraEditors.DateEdit”和“DevExpress.XtraEditors.TimeEdit”下的字段类型相同,但获取并将其值保存到调度程序映射中映射的自定义字段 自定义字段定义为属性: Public Class MyA
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
然后单击“确定”:
当代码到达controller.ApplyChanges时,我得到以下错误:
发生格式化异常
输入sting的格式不正确
故障排除提示:
将字符串转换为日期时间时,解析字符串以获取
将每个变量放入DateTime对象之前的日期
我试过DateTime.Parse,DateTime.ParseExact,Date.Parse,Date.ParseExact,先指定日期,然后添加时间,还有很多其他的方法,但我就是无法克服这个问题
如何将自定义任命编辑表单中的日期保存回sql数据库。我真的希望使用自定义约会属性使它变得简单
我只担心公布的开始和结束日期和时间
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