This repository has been archived by the owner on Sep 25, 2023. It is now read-only.
/
CustomAppointmentForm.ascx.vb
62 lines (53 loc) · 2.7 KB
/
CustomAppointmentForm.ascx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DevExpress.XtraScheduler
Imports DevExpress.Web
Imports DevExpress.Web.Internal
Imports System.IO
Namespace WebApplication1.CustomControls
Partial Public Class CustomAppointmentForm
Inherits System.Web.UI.UserControl
Private Const UploadDirectory As String = "~/Images/"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Public Overrides Sub DataBind()
MyBase.DataBind()
Dim container As CustomAppointmentFormTemplateContainer = CType(Parent, CustomAppointmentFormTemplateContainer)
ASPxTextBoxSubject.Text = container.Subject
ASPxDateEditStart.Value = container.Start
ASPxDateEditEnd.Value = container.End
ASPxMemoDescription.Text = container.Description
ASPxTextBoxCustomInfo.Text = container.CustomInfoField
If container.CustomAttachmentFileName <> "" Then
ASPxImage1.ImageUrl = "~/" & container.CustomAttachmentFileName
End If
ASPxLabelFileName.Text = container.CustomAttachmentFileName
ASPxButtonOk.ClientSideEvents.Click = container.CancelHandler
ASPxButtonCancel.ClientSideEvents.Click = container.CancelHandler
ASPxButtonDelete.ClientSideEvents.Click = container.DeleteHandler
End Sub
Protected Sub ASPxUploadControl1_FileUploadComplete(ByVal sender As Object, ByVal e As DevExpress.Web.FileUploadCompleteEventArgs)
Dim control As ASPxUploadControl = TryCast(sender, ASPxUploadControl)
Dim container As CustomAppointmentFormTemplateContainer = CType(Parent, CustomAppointmentFormTemplateContainer)
Dim callback As String = SavePostedFiles(e.UploadedFile)
container.Appointment.CustomFields("AppointmentAttachment") = e.UploadedFile.FileBytes
container.Appointment.CustomFields("AppointmentAttachmentFileName") = callback
e.CallbackData = callback
End Sub
Private Function SavePostedFiles(ByVal uploadedFile As UploadedFile) As String
If Not uploadedFile.IsValid Then
Return String.Empty
End If
Dim fileInfo As New FileInfo(uploadedFile.FileName)
Dim resFileName As String = MapPath(UploadDirectory) & fileInfo.Name
uploadedFile.SaveAs(resFileName)
resFileName = "Images/" & fileInfo.Name
UploadingUtils.RemoveFileWithDelay(uploadedFile.FileName, resFileName, 5)
Return resFileName
End Function
End Class
End Namespace