-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChapterEntry.aspx.vb
108 lines (96 loc) · 3.4 KB
/
ChapterEntry.aspx.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Partial Class ChapterEntry
Inherits System.Web.UI.Page
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Try
If (Session.Item("UserName") Is Nothing) Or (Session.Item("UserName") = "") Then
Response.Redirect("Login2.aspx")
End If
If Not IsPostBack Then
hdnId.Value = 0
loadData()
End If
If (Not IsPostBack) Then
hdnId.Value = 0
LoadCombo()
loadData()
End If
Catch ex As Exception
End Try
End Sub
Private Sub LoadCombo()
Try
Dim sql As String
Dim Fun As New clsFunctions
sql = "select id,Name from Subject_Master "
Fun.FillCombo(sql, ddlSubject)
ddlSubject.Items.Insert(0, "---Select Subject---")
Catch ex As Exception
End Try
End Sub
Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
Try
Dim Chapter As New clsChapter_Master
Chapter.init()
Chapter.Id = hdnId.Value
Chapter.Name = txtName.Text
Chapter.Subject_Id = ddlSubject.Text
If Not is_Valid() Then Exit Sub
If Chapter.Save = True Then
MesgBox("Chapter saved successfully")
ClearAll()
Else
MesgBox("Error while saving record")
End If
Catch ex As Exception
MesgBox("Error:" & ex.Message)
End Try
End Sub
Private Sub loadData()
Try
Dim ID As Long
ID = Val(Page.Request.QueryString("Id").ToString())
Dim Chapter As New clsChapter_Master
Chapter.Id = ID
Chapter.GetById()
ddlSubject.SelectedValue = Chapter.Subject_Id
hdnId.Value = ID
txtName.Text = Chapter.Name
Catch ex As Exception
End Try
End Sub
Private Function is_Valid() As Boolean
Try
Dim sql As String
Dim con As New clsConnection
Dim Fun As New clsFunctions
is_Valid = True
If hdnId.Value <> 0 Then
sql = "select count(*) from Chapter_Master where Subject_ID=" & Fun.SQLString(ddlSubject.Text)
sql = sql & " and Name=" & Fun.SQLString(txtName.Text)
sql = sql & " and id<>" & Fun.SQLNumber(hdnId.Value)
Else
sql = "select count(*) from Chapter_Master where Subject_ID=" & Fun.SQLString(ddlSubject.Text)
sql = sql & " and Name=" & Fun.SQLString(txtName.Text)
End If
If con.GetValue(sql) >= 1 Then
MesgBox("Chapter Already Available")
txtName.Focus()
is_Valid = False
End If
Catch ex As Exception
is_Valid = False
End Try
End Function
Private Sub ClearAll()
ddlSubject.SelectedIndex = 0
txtName.Text = " "
End Sub
Private Sub MesgBox(ByVal sMessage As String)
Dim msg As String
msg = "<script language='javascript'>"
msg += "alert('" & sMessage & "');"
msg += "<" & "/script>"
Response.Write(msg)
End Sub
End Class