Server IP : 103.118.17.23 / Your IP : 216.73.216.169 Web Server : Microsoft-IIS/10.0 System : Windows NT RESELLERPLESK22 10.0 build 20348 (Windows Server 2016) AMD64 User : IWAM_plesk(default) ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/vhosts/mesa.org.in/httpdocs/grievance/ |
Upload File : |
<% ' ASPMaker configuration for Table Grievance Dim Grievance ' Define table class Class cGrievance Dim TableDBID Dim UpdateTable Dim Fields ' Fields Dim Rows ' Data for Custom Template ' Column CSS classes Dim LeftColumnClass, RightColumnClass, OffsetColumnClass Dim UseSessionForListSQL ' Class Initialize Private Sub Class_Initialize() Set Fields = Dictionary() Set Rows = Dictionary() UseTokenInUrl = EW_USE_TOKEN_IN_URL ExportAll = True UpdateTable = "dbo.Grievance" TableDBID = "DB" ExportPageBreakCount = 0 ' Page break per every n record (PDF only) ExportPageOrientation = "portrait" ' Page orientation (PDF only) ExportPageSize = "a4" ' Page size (PDF only) Set RowAttrs = New cAttributes ' Row attributes AllowAddDeleteRow = ew_AllowAddDeleteRow() ' Allow add/delete row DetailAdd = False ' Allow detail add DetailEdit = False ' Allow detail edit DetailView = False ' Allow detail view ShowMultipleDetails = False ' Show multiple details GridAddRowCount = 5 ' Grid add row count ValidateKey = True ' Validate key Visible = True BasicSearch.TblVar = TableVar BasicSearch.KeywordDefault = "" BasicSearch.SearchTypeDefault = "" UserIDAllowSecurity = 0 ' User ID Allow Call Fields.Add("ID", ID) Call Fields.Add("Name", Name) Call Fields.Add("SEmail", SEmail) Call Fields.Add("Email", zEmail) Call Fields.Add("Password", Password) Call Fields.Add("Mobile", Mobile) Call Fields.Add("Gender", Gender) Call Fields.Add("Department", Department) Call Fields.Add("Grievance", Grievance_1) Call Fields.Add("Docs", Docs) Call Fields.Add("Agree", Agree) LeftColumnClass = "col-sm-2 control-label ewLabel" RightColumnClass = "col-sm-10" OffsetColumnClass = "col-sm-10 col-sm-offset-2" UseSessionForListSQL = True End Sub ' Connection Function TableConnection() Set TableConnection = ew_GetConn(TableDBID) End Function ' Database type Function TableDbType() TableDbType = ew_GetConnectionType(TableDBID) End Function ' Cursor location Function TableCursorLocation() TableCursorLocation = 3 End Function ' Record lock type Function TableRecordsetLockType() TableRecordsetLockType = 2 End Function ' Reset attributes for table object Public Sub ResetAttrs() CssClass = "" CssStyle = "" Call RowAttrs.Clear Dim fld, keys, key If IsDictionary(Fields) Then keys = Fields.Keys() For Each key In keys Set fld = Fields.Get(key) Call fld.ResetAttrs Next End If End Sub ' Setup field titles Public Sub SetupFieldTitles() Dim fld, keys, key If IsDictionary(Fields) Then keys = Fields.Keys() For Each key In keys Set fld = Fields.Get(key) If fld.FldTitle <> "" Then Call fld.EditAttrs.Update("data-toggle", "tooltip") Call fld.EditAttrs.Update("title", ew_HtmlEncode(fld.FldTitle)) End If Next End If End Sub ' Get field cell attributes Function FieldCellAttributes() Dim fld, values, keys, key Set values = Dictionary() If IsDictionary(Fields) Then keys = Fields.Keys() For Each key In keys Set fld = Fields.Get(key) Call values.Add(fld.FldParm, fld.CellAttributes) Next End If FieldCellAttributes = values End Function ' Get field DB values for Custom Template Function CustomTemplateFieldValues() Dim fld, values, keys, key Set values = Dictionary() If IsDictionary(Fields) Then keys = Fields.Keys() For Each key In keys Set fld = Fields.Get(key) If ew_InArray(fld.FldDataType, EW_CUSTOM_TEMPLATE_DATATYPES) Then If VarType(fld.DbValue) = 8 Then ' VarType = vbString If Len(fld.DbValue) > EW_DATA_STRING_MAX_LENGTH Then Call values.Add(fld.FldParm, Left(fld.DbValue, EW_DATA_STRING_MAX_LENGTH)) Else Call values.Add(fld.FldParm, fld.DbValue) End If Else Call values.Add(fld.FldParm, fld.DbValue) End If End If Next End If Set CustomTemplateFieldValues = values End Function ' Define table level constants ' Use table token in Url Dim UseTokenInUrl ' Table variable Public Property Get TableVar TableVar = "Grievance" End Property ' Table name Public Property Get TableName TableName = "Grievance" End Property ' Table type Public Property Get TableType TableType = "TABLE" End Property ' Table caption Dim Caption Public Property Let TableCaption(v) Caption = v End Property Public Property Get TableCaption If Caption & "" <> "" Then TableCaption = Caption Else TableCaption = Language.TablePhrase(TableVar, "TblCaption") End If End Property ' Page caption Dim PgCaption Public Property Let PageCaption(Page, v) If Not IsArray(PgCaption) Then ReDim PgCaption(Page) ElseIf Page > UBound(PgCaption) Then ReDim Preserve PgCaption(Page) End If PgCaption(Page) = v End Property Public Property Get PageCaption(Page) PageCaption = "" If IsArray(PgCaption) Then If Page <= UBound(PgCaption) Then PageCaption = PgCaption(Page) End If End If If PageCaption = "" Then PageCaption = Language.TablePhrase(TableVar, "TblPageCaption" & Page) If PageCaption = "" Then PageCaption = "Page " & Page End Property Dim Visible ' Export Return Page Public Property Get ExportReturnUrl If Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_EXPORT_RETURN_URL) <> "" Then ExportReturnUrl = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_EXPORT_RETURN_URL) Else ExportReturnUrl = ew_CurrentPage End If End Property Public Property Let ExportReturnUrl(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_EXPORT_RETURN_URL) = v End Property ' Records per page Public Property Get RecordsPerPage RecordsPerPage = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_REC_PER_PAGE) End Property Public Property Let RecordsPerPage(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_REC_PER_PAGE) = v End Property ' Start record number Public Property Get StartRecordNumber StartRecordNumber = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_START_REC) End Property Public Property Let StartRecordNumber(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_START_REC) = v End Property ' Search Highlight Name Public Property Get HighlightName HighlightName = "Grievance_Highlight" End Property ' Search highlight value Public Function HighlightValue(fld) Dim kwlist, dict, akw, src, src1, pos1, pos2, val, Match, Matches kwlist = BasicSearch.KeywordList(False) If BasicSearch.SearchType = "" Then ' Auto, remove ALL "OR" kwlist = ew_ArrayDiff(kwlist, Array("OR")) End If Set dict = Dictionary(kwlist) akw = fld.AdvancedSearch.GetValue("x") If Len(akw) > 0 Then dict.Push akw akw = fld.AdvancedSearch.GetValue("y") If Len(akw) > 0 Then dict.Push akw src = fld.ViewValue & "" If dict.Count() = 0 Then HighlightValue = src Exit Function End If pos1 = 0 val = "" If ew_RegExMatch("<([^>]*)>", src, Matches) Then For Each Match In Matches pos2 = Match.FirstIndex If pos2 > pos1 Then src1 = Mid(src, pos1+1, pos2-pos1) val = val & Highlight(dict.ToArray(), src1) End If val = val & Match pos1 = pos2 + Len(Match) Next End If pos2 = Len(src) If pos2 > pos1 Then src1 = Mid(src, pos1+1, pos2-pos1) val = val & Highlight(dict.ToArray(), src1) End If HighlightValue = val End Function ' Highlight keyword Private Function Highlight(kwlist, src) Dim pattern, kw, RE, dest pattern = "" For Each kw In kwlist pattern = pattern & ew_IIf(pattern = "", "", "|") & ew_RegExEscape(kw) Next If pattern = "" Then Highlight = src Exit Function End If pattern = "(" & pattern & ")" dest = "<span class=""" & HighlightName() & " ewHighlightSearch"">$1</span>" If EW_HIGHLIGHT_COMPARE Then src = ew_RegExReplace(pattern, src, dest, "ig") ELSE src = ew_RegExReplace(pattern, src, dest, "g") End If Highlight = src End Function ' Search where clause Public Property Get SearchWhere SearchWhere = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_SEARCH_WHERE) End Property Public Property Let SearchWhere(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_SEARCH_WHERE) = v End Property ' Field Visibility Function GetFieldVisibility(fldparm) ' Returns original value GetFieldVisibility = GetFieldByParm(fldparm).Visible End Function ' Set left column class (must be predefined col-*-* classes of Bootstrap grid system) Function SetLeftColumnClass(sClass) Dim matches, m If ew_RegExMatch("^col\-(\w+)\-(\d+)$", sClass, matches) Then Set m = matches(0) LeftColumnClass = sClass & " control-label ewLabel" RightColumnClass = "col-" & m.SubMatches(0) & "-" & CStr(12 - CInt(m.SubMatches(1))) OffsetColumnClass = RightColumnClass & " " & Replace(sClass, m.SubMatches(0), m.SubMatches(0) + "-offset") Set m = Nothing End If End Function ' Single column sort Public Sub UpdateSort(ofld) Dim sSortField, sLastSort, sThisSort If CurrentOrder = ofld.FldName Then sSortField = ofld.FldExpression sLastSort = ofld.Sort If CurrentOrderType = "ASC" Or CurrentOrderType = "DESC" Then sThisSort = CurrentOrderType Else If sLastSort = "ASC" Then sThisSort = "DESC" Else sThisSort = "ASC" End If ofld.Sort = sThisSort SessionOrderBy = sSortField & " " & sThisSort ' Save to Session Else ofld.Sort = "" End If End Sub ' BasicSearch Object Private m_BasicSearch Public Property Get BasicSearch If ew_Empty(m_BasicSearch) Then Set m_BasicSearch = New cBasicSearch End If Set BasicSearch = m_BasicSearch End Property ' Session WHERE Clause Public Property Get SessionWhere SessionWhere = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_WHERE) End Property Public Property Let SessionWhere(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_WHERE) = v End Property ' Session ORDER BY Public Property Get SessionOrderBy SessionOrderBy = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ORDER_BY) End Property Public Property Let SessionOrderBy(v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_ORDER_BY) = v End Property ' Session Key Public Function GetKey(fld) GetKey = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_KEY & "_" & fld) End Function Public Function SetKey(fld, v) Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_KEY & "_" & fld) = v End Function ' Table level SQL ' From Private zSqlFrom Public Property Get SqlFrom SqlFrom = ew_IIf(zSqlFrom & "" <> "", zSqlFrom, "dbo.Grievance") End Property Public Property Let SqlFrom(v) zSqlFrom = v End Property ' Select Private zSqlSelect Public Property Get SqlSelect SqlSelect = ew_IIf(zSqlSelect & "" <> "", zSqlSelect, "SELECT * FROM dbo.Grievance") End Property Public Property Let SqlSelect(v) zSqlSelect = v End Property Private Property Get TableFilter TableFilter = "" End Property ' Where Private zSqlWhere Public Property Get SqlWhere Dim sWhere sWhere = ew_IIf(zSqlWhere & "" <> "", zSqlWhere, "") Call ew_AddFilter(sWhere, TableFilter) SqlWhere = sWhere End Property Public Property Let SqlWhere(v) zSqlWhere = v End Property ' Group By Private zSqlGroupBy Public Property Get SqlGroupBy SqlGroupBy = ew_IIf(zSqlGroupBy & "" <> "", zSqlGroupBy, "") End Property Public Property Let SqlGroupBy(v) zSqlGroupBy = v End Property ' Having Private zSqlHaving Public Property Get SqlHaving SqlHaving = ew_IIf(zSqlHaving & "" <> "", zSqlHaving, "") End Property Public Property Let SqlHaving(v) zSqlHaving = v End Property ' Order By Private zSqlOrderBy Public Property Get SqlOrderBy SqlOrderBy = ew_IIf(zSqlOrderBy & "" <> "", zSqlOrderBy, "") End Property Public Property Let SqlOrderBy(v) zSqlOrderBy = v End Property ' SQL variables Dim CurrentFilter ' Current filter Dim CurrentOrder ' Current order Dim CurrentOrderType ' Current order type ' Get SQL Public Function GetSQL(where, orderby) GetSQL = ew_BuildSelectSql(SqlSelect, SqlWhere, SqlGroupBy, SqlHaving, SqlOrderBy, where, orderby) End Function ' Table SQL Public Property Get SQL Dim sFilter, sSort sFilter = CurrentFilter sSort = SessionOrderBy SQL = GetSQL(sFilter, sSort) End Property ' Select SQL for Insert/Update/Delete Public Property Get UpdateTableSQL Dim sSelect, sFilter sSelect = ew_IIf(UpdateTable <> "", "SELECT * FROM " & UpdateTable, SqlSelect) sFilter = CurrentFilter UpdateTableSQL = ew_BuildSelectSql(sSelect, SqlWhere, SqlGroupBy, SqlHaving, "", sFilter, "") End Property ' Return table SQL with list page filter Public Property Get ListSQL Dim sFilter, sSort, sSelect sFilter = ew_IIf(UseSessionForListSQL, SessionWhere, "") Call ew_AddFilter(sFilter, CurrentFilter) Call Recordset_Selecting(sFilter) sSelect = SqlSelect sSort = ew_IIf(UseSessionForListSQL, SessionOrderBy, "") ListSQL = ew_BuildSelectSql(sSelect, SqlWhere, SqlGroupBy, SqlHaving, SqlOrderBy, sFilter, sSort) End Property ' Key filter for table Private Property Get SqlKeyFilter SqlKeyFilter = "ID = @ID@" End Property ' Return Key filter for table Public Property Get KeyFilter Dim sKeyFilter sKeyFilter = SqlKeyFilter If Not IsNumeric(ID.CurrentValue) Then KeyFilter = "0=1" ' Invalid key Exit Property End If If IsNull(ID.CurrentValue) Then KeyFilter = "0=1" ' Invalid key Exit Property Else sKeyFilter = Replace(sKeyFilter, "@ID@", ew_AdjustSqlBase(ID.CurrentValue, TableDBID)) ' Replace key value End If KeyFilter = sKeyFilter End Property ' Return URL Public Property Get ReturnUrl ' Get referer URL automatically If Request.ServerVariables("HTTP_REFERER") <> "" Then If ew_ReferPage <> ew_CurrentPage And ew_ReferPage <> "login.asp" Then ' Referer not same page or login page Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL) = Request.ServerVariables("HTTP_REFERER") ' Save to Session End If End If If Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL) <> "" Then ReturnUrl = Session(EW_PROJECT_NAME & "_" & TableVar & "_" & EW_TABLE_RETURN_URL) Else ReturnUrl = "Grievancelist.asp" End If End Property ' Get modal caption Public Function GetModalCaption(pageName) If pageName = "Grievanceview.asp" Then GetModalCaption = Language.Phrase("View") ElseIf pageName = "Grievanceedit.asp" Then GetModalCaption = Language.Phrase("Edit") ElseIf pageName = "Grievanceadd.asp" Then GetModalCaption = Language.Phrase("Add") Else GetModalCaption = "" End If End Function ' List URL Public Function ListUrl() ListUrl = "Grievancelist.asp" End Function ' View URL Public Function ViewUrl(parm) Dim url If parm <> "" Then url = KeyUrl("Grievanceview.asp", UrlParm(parm)) Else url = KeyUrl("Grievanceview.asp", UrlParm(EW_TABLE_SHOW_DETAIL & "=")) End If ViewUrl = AddMasterUrl(url) End Function ' Add URL Public Function AddUrl(parm) Dim url If parm <> "" Then url = "Grievanceadd.asp?" & UrlParm(parm) Else url = "Grievanceadd.asp" End If AddUrl = AddMasterUrl(url) End Function ' Edit URL Public Function EditUrl(parm) Dim url url = KeyUrl("Grievanceedit.asp", UrlParm(parm)) EditUrl = AddMasterUrl(url) End Function ' Inline edit URL Public Function InlineEditUrl() Dim url url = KeyUrl(ew_CurrentPage, UrlParm("a=edit")) InlineEditUrl = AddMasterUrl(url) End Function ' Copy URL Public Function CopyUrl(parm) Dim url url = KeyUrl("Grievanceadd.asp", UrlParm(parm)) CopyUrl = AddMasterUrl(url) End Function ' Inline copy URL Public Function InlineCopyUrl() Dim url url = KeyUrl(ew_CurrentPage, UrlParm("a=copy")) InlineCopyUrl = AddMasterUrl(url) End Function ' Delete URL Public Function DeleteUrl() DeleteUrl = KeyUrl("Grievancedelete.asp", UrlParm("")) End Function ' Add master URL Public Function AddMasterUrl(url) Dim wrkurl wrkurl = url AddMasterUrl = wrkurl End Function ' Key to JSON Public Function KeyToJson() Dim json json = "" json = json & ("ID:" & ew_VarToJson(ID.CurrentValue, "number", "'")) KeyToJson = "{" & json & "}" End Function ' Key URL Public Function KeyUrl(url, parm) Dim sUrl: sUrl = url & "?" If parm <> "" Then sUrl = sUrl & parm & "&" If Not IsNull(ID.CurrentValue) Then sUrl = sUrl & "ID=" & ID.CurrentValue Else KeyUrl = "javascript:ew_Alert(ewLanguage.Phrase('InvalidRecord'));" Exit Function End If KeyUrl = sUrl End Function ' Sort URL Public Property Get SortUrl(fld) If CurrentAction <> "" Or Export <> "" Or (fld.FldType = 201 Or fld.FldType = 203 Or fld.FldType = 205 Or fld.FldType = 141) Then SortUrl = "" ElseIf fld.Sortable Then SortUrl = ew_CurrentPage Dim sUrlParm sUrlParm = UrlParm("order=" & ew_UrlEncode(fld.FldName) & "&ordertype=" & fld.ReverseSort) SortUrl = AddMasterUrl(SortUrl & "?" & sUrlParm) Else SortUrl = "" End If End Property ' URL parm Function UrlParm(parm) If UseTokenInUrl Then UrlParm = "t=Grievance" Else UrlParm = "" End If If parm <> "" Then If UrlParm <> "" Then UrlParm = UrlParm & "&" UrlParm = UrlParm & parm End If End Function ' Get record keys from Form/QueryString/Session Public Function GetRecordKeys() Dim arKeys, arKey, cnt, i, bHasKey bHasKey = False ' Check ObjForm first If ew_NotEmpty(ObjForm) Then ObjForm.Index = -1 If ObjForm.HasValue("key_m") Then arKeys = ObjForm.GetValue("key_m") If Not IsArray(arKeys) Then arKeys = Array(arKeys) End If bHasKey = True End If End If ' Check Form/QueryString If Not bHasKey Then If Request.Form("key_m").Count > 0 Then cnt = Request.Form("key_m").Count ReDim arKeys(cnt-1) For i = 1 to cnt ' Set up keys arKeys(i-1) = Request.Form("key_m")(i) Next ElseIf Request.QueryString("key_m").Count > 0 Then cnt = Request.QueryString("key_m").Count ReDim arKeys(cnt-1) For i = 1 to cnt ' Set up keys arKeys(i-1) = Request.QueryString("key_m")(i) Next ElseIf Request.QueryString <> "" Or Request.Form <> "" Then Dim isPost isPost = ew_IsHttpPost() ReDim arKeys(0) If isPost And Request.Form("ID").Count > 0 Then arKeys(0) = Request.Form("ID") ElseIf Request.QueryString("ID").Count > 0 Then arKeys(0) = Request.QueryString("ID") Else arKeys = "" ' Do not setup End If 'GetRecordKeys = arKeys ' Do not return yet, so the values will also be checked by the following code End If End If ' Check keys Dim ar, key If IsArray(arKeys) Then For i = 0 to UBound(arKeys) key = arKeys(i) Dim skip skip = False If Not IsNumeric(key) Then skip = True If Not skip Then If IsArray(ar) Then ReDim Preserve ar(UBound(ar)+1) Else ReDim ar(0) End If ar(UBound(ar)) = key End If Next End If GetRecordKeys = ar End Function ' Get key filter Public Function GetKeyFilter() Dim arKeys, sKeyFilter, i, key arKeys = GetRecordKeys() sKeyFilter = "" If IsArray(arKeys) Then For i = 0 to UBound(arKeys) key = arKeys(i) If sKeyFilter <> "" Then sKeyFilter = sKeyFilter & " OR " ID.CurrentValue = key sKeyFilter = sKeyFilter & "(" & KeyFilter & ")" Next End If GetKeyFilter = sKeyFilter End Function ' Get record count based on filter (for detail record count in master table pages) Public Function LoadRecordCount(filter) Dim sql, cnt, cnn, sFilter, rs, sSelect, sGroupBy, sHaving sFilter = filter Call Recordset_Selecting(sFilter) sSelect = ew_IIf(TableType = "CUSTOMVIEW", SqlSelect, "SELECT * FROM " & SqlFrom) sGroupBy = ew_IIf(TableType = "CUSTOMVIEW", SqlGroupBy, "") sHaving = ew_IIf(TableType = "CUSTOMVIEW", SqlHaving, "") sql = ew_BuildSelectSql(sSelect, SqlWhere, sGroupBy, sHaving, "", sFilter, "") cnt = ew_GetRecordCount(sql, TableDBID) ' ASP If cnt = -1 Then Set cnn = TableConnection() Set rs = cnn.Execute(sql) cnt = rs.RecordCount rs.Close() Set rs = Nothing Set cnn = Nothing End If LoadRecordCount = cnt End Function ' Get record count (for current List page) Public Function ListRecordCount() Dim sql, cnt, cnn, sFilter, rs, sSelect, sGroupBy, sHaving sFilter = SessionWhere Call ew_AddFilter(sFilter, CurrentFilter) Call Recordset_Selecting(sFilter) sSelect = ew_IIf(TableType = "CUSTOMVIEW", SqlSelect, "SELECT * FROM " & SqlFrom) sGroupBy = ew_IIf(TableType = "CUSTOMVIEW", SqlGroupBy, "") sHaving = ew_IIf(TableType = "CUSTOMVIEW", SqlHaving, "") sql = ew_BuildSelectSql(sSelect, SqlWhere, sGroupBy, sHaving, "", sFilter, "") cnt = ew_GetRecordCount(sql, TableDBID) ' ASP If cnt = -1 Then Set cnn = TableConnection() Set rs = cnn.Execute(sql) cnt = rs.RecordCount rs.Close() Set rs = Nothing Set cnn = Nothing End If ListRecordCount = cnt End Function ' Function LoadRs ' Load Rows based on filter Public Function LoadRs(filter) If Not EW_DEBUG_ENABLED Then On Error Resume Next Dim cnn, RsRows, sql ' Set up filter (SQL WHERE Clause) and get SQL 'CurrentFilter = filter 'sSql = SQL sql = GetSQL(filter, "") Set cnn = TableConnection Err.Clear Set RsRows = Server.CreateObject("ADODB.Recordset") RsRows.CursorLocation = TableCursorLocation Call ew_SetDebugMsg("LoadRs: " & sql) ' Show SQL for debugging RsRows.Open sql, cnn, 3, 1, 1 ' adOpenStatic, adLockReadOnly, adCmdText If Err.Number <> 0 Then Err.Clear Set LoadRs = Nothing RsRows.Close Set RsRows = Nothing ElseIf RsRows.EOF Then Set LoadRs = Nothing RsRows.Close Set RsRows = Nothing Else Set LoadRs = RsRows End If End Function ' Load row values from recordset Public Sub LoadListRowValues(RsRow) ID.DbValue = RsRow("ID") Name.DbValue = RsRow("Name") SEmail.DbValue = RsRow("SEmail") zEmail.DbValue = RsRow("Email") Password.DbValue = RsRow("Password") Mobile.DbValue = RsRow("Mobile") Gender.DbValue = RsRow("Gender") Department.DbValue = RsRow("Department") Grievance_1.DbValue = RsRow("Grievance") Docs.Upload.DbValue = RsRow("Docs") Agree.DbValue = RsRow("Agree") End Sub ' Render list row values Sub RenderListRow() ' ' Common render codes ' ' ID ' Name ' SEmail ' Email ' Password ' Mobile ' Gender ' Department ' Grievance ' Docs ' Agree ' Call Row Rendering event Call Row_Rendering ' ' Render for View ' ' ID ID.ViewValue = ID.CurrentValue ID.ViewCustomAttributes = "" ' Name Name.ViewValue = Name.CurrentValue Name.ViewCustomAttributes = "" ' SEmail SEmail.ViewValue = SEmail.CurrentValue SEmail.ViewCustomAttributes = "" ' Email zEmail.ViewValue = zEmail.CurrentValue zEmail.ViewCustomAttributes = "" ' Password Password.ViewValue = Password.CurrentValue Password.ViewCustomAttributes = "" ' Mobile Mobile.ViewValue = Mobile.CurrentValue Mobile.ViewCustomAttributes = "" ' Gender If Not IsNull(Gender.CurrentValue) Then Gender.ViewValue = Gender.OptionCaption(Gender.CurrentValue) Else Gender.ViewValue = Null End If Gender.ViewCustomAttributes = "" ' Department Department.ViewValue = Department.CurrentValue Department.ViewCustomAttributes = "" ' Grievance Grievance_1.ViewValue = Grievance_1.CurrentValue Grievance_1.ViewCustomAttributes = "" ' Docs Docs.UploadPath = "../uploads/grievance" If Not ew_Empty(Docs.Upload.DbValue) Then Docs.ViewValue = Docs.Upload.DbValue Docs.ViewValue = Docs.Upload.DbValue Else Docs.ViewValue = "" End If Docs.ViewCustomAttributes = "" ' Agree If Not IsNull(Agree.CurrentValue) Then Agree.ViewValue = Agree.OptionCaption(Agree.CurrentValue) Else Agree.ViewValue = Null End If Agree.ViewCustomAttributes = "" ' ID ID.LinkCustomAttributes = "" ID.HrefValue = "" ID.TooltipValue = "" ' Name Name.LinkCustomAttributes = "" Name.HrefValue = "" Name.TooltipValue = "" ' SEmail SEmail.LinkCustomAttributes = "" SEmail.HrefValue = "" SEmail.TooltipValue = "" ' Email zEmail.LinkCustomAttributes = "" zEmail.HrefValue = "" zEmail.TooltipValue = "" ' Password Password.LinkCustomAttributes = "" Password.HrefValue = "" Password.TooltipValue = "" ' Mobile Mobile.LinkCustomAttributes = "" Mobile.HrefValue = "" Mobile.TooltipValue = "" ' Gender Gender.LinkCustomAttributes = "" Gender.HrefValue = "" Gender.TooltipValue = "" ' Department Department.LinkCustomAttributes = "" Department.HrefValue = "" Department.TooltipValue = "" ' Grievance Grievance_1.LinkCustomAttributes = "" Grievance_1.HrefValue = "" Grievance_1.TooltipValue = "" ' Docs Docs.LinkCustomAttributes = "" Docs.HrefValue = "" Docs.HrefValue2 = Docs.UploadPath & Docs.Upload.DbValue Docs.TooltipValue = "" ' Agree Agree.LinkCustomAttributes = "" Agree.HrefValue = "" Agree.TooltipValue = "" ' Call Row Rendered event If RowType <> EW_ROWTYPE_AGGREGATEINIT Then Call Row_Rendered End If ' Save data for Custom Template Call Rows.Push(CustomTemplateFieldValues()) End Sub ' Render edit row values Public Sub RenderEditRow() ' Call Row Rendering event Call Row_Rendering ' ID Call ID.EditAttrs.UpdateAttribute("class", "form-control") ID.EditCustomAttributes = "" ID.EditValue = ID.CurrentValue ID.ViewCustomAttributes = "" ' Name Call Name.EditAttrs.UpdateAttribute("class", "form-control") Name.EditCustomAttributes = "" Name.EditValue = Name.CurrentValue Name.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Name.FldCaption)) ' SEmail Call SEmail.EditAttrs.UpdateAttribute("class", "form-control") SEmail.EditCustomAttributes = "" SEmail.EditValue = SEmail.CurrentValue SEmail.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(SEmail.FldCaption)) ' Email Call zEmail.EditAttrs.UpdateAttribute("class", "form-control") zEmail.EditCustomAttributes = "" zEmail.EditValue = zEmail.CurrentValue zEmail.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zEmail.FldCaption)) ' Password Call Password.EditAttrs.UpdateAttribute("class", "form-control") Password.EditCustomAttributes = "" Password.EditValue = Password.CurrentValue Password.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Password.FldCaption)) ' Mobile Call Mobile.EditAttrs.UpdateAttribute("class", "form-control") Mobile.EditCustomAttributes = "" Mobile.EditValue = Mobile.CurrentValue Mobile.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Mobile.FldCaption)) ' Gender Gender.EditCustomAttributes = "" Gender.EditValue = Grievance.Gender.Options(False) ' Department Call Department.EditAttrs.UpdateAttribute("class", "form-control") Department.EditCustomAttributes = "" Department.EditValue = Department.CurrentValue Department.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Department.FldCaption)) ' Grievance Call Grievance_1.EditAttrs.UpdateAttribute("class", "form-control") Grievance_1.EditCustomAttributes = "" Grievance_1.EditValue = Grievance_1.CurrentValue Grievance_1.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(Grievance_1.FldCaption)) ' Docs Call Docs.EditAttrs.UpdateAttribute("class", "form-control") Docs.EditCustomAttributes = "" Docs.UploadPath = "../uploads/grievance" If Not ew_Empty(Docs.Upload.DbValue) Then Docs.EditValue = Docs.Upload.DbValue Docs.EditValue = Docs.Upload.DbValue Else Docs.EditValue = "" End If ' Agree Agree.EditCustomAttributes = "" Agree.EditValue = Grievance.Agree.Options(False) ' Call Row Rendered event Call Row_Rendered End Sub ' Aggregate list row values Public Sub AggregateListRowValues() End Sub ' Aggregate list row (for rendering) Sub AggregateListRow() ' Call Row Rendered event Call Row_Rendered End Sub ' Update detail records Function UpdateDetailRecords(RsOld, RsNew) Dim bUpdate, sFieldList, sWhereList, sSql, rscascade, rscascadenew, cnn On Error Resume Next UpdateDetailRecords = True End Function ' Delete detail records Function DeleteDetailRecords(Rs, Where) On Error Resume Next Dim sWhereList, sWhereWrk, sSql, cnn, bNullRs, RsWrk, rscascade bNullRs = IsNull(Rs) DeleteDetailRecords = True ' Delete upload files if necessary If bNullRs Then Dim rsfile sSql = "SELECT * FROM dbo.Grievance WHERE " & Where Set cnn = TableConnection Set rsfile = cnn.Execute(sSql) If Not rsfile.EOF Then rsfile.MoveFirst Do While Not rsfile.EOF Call LoadListRowValues(rsfile) Docs.UploadPath = "../uploads/grievance" If ew_NotEmpty(Docs.Upload.DbValue) Then Call ew_DeleteFile(ew_UploadPathEx(True, Docs.UploadPath) & Docs.Upload.DbValue) End If rsfile.MoveNext Loop rsfile.Close Set rsfile = Nothing End If End Function ' Export data in Xml Format Public Sub ExportXmlDocument(XmlDoc, HasParent, Recordset, StartRec, StopRec, ExportPageType) If ew_Empty(Recordset) Or ew_Empty(XmlDoc) Then Exit Sub End If If Not HasParent Then Call XmlDoc.AddRoot(TableVar) End If ' Move to first record Dim RecCnt, RowCnt RecCnt = StartRec - 1 If Not Recordset.EOF Then ' Already positioned at first record, no need to move 'Recordset.MoveFirst 'If StartRec > 1 Then Recordset.Move(StartRec - 1) End If Do While Not Recordset.EOF And RecCnt < StopRec RecCnt = RecCnt + 1 If CLng(RecCnt) >= CLng(StartRec) Then RowCnt = CLng(RecCnt) - CLng(StartRec) + 1 Call LoadListRowValues(Recordset) ' Render row RowType = EW_ROWTYPE_VIEW ' Render view Call ResetAttrs Call RenderListRow If HasParent Then Call XmlDoc.AddRow(TableVar, "") Else Call XmlDoc.AddRow("", "") End If If ExportPageType = "view" Then Call XmlDoc.AddField("ID", ID.ExportValue(Export)) Call XmlDoc.AddField("Name", Name.ExportValue(Export)) Call XmlDoc.AddField("SEmail", SEmail.ExportValue(Export)) Call XmlDoc.AddField("zEmail", zEmail.ExportValue(Export)) Call XmlDoc.AddField("Password", Password.ExportValue(Export)) Call XmlDoc.AddField("Mobile", Mobile.ExportValue(Export)) Call XmlDoc.AddField("Gender", Gender.ExportValue(Export)) Call XmlDoc.AddField("Department", Department.ExportValue(Export)) Call XmlDoc.AddField("Grievance_1", Grievance_1.ExportValue(Export)) Call XmlDoc.AddField("Docs", Docs.Upload.DbValue) Call XmlDoc.AddField("Agree", Agree.ExportValue(Export)) Else Call XmlDoc.AddField("ID", ID.ExportValue(Export)) Call XmlDoc.AddField("Name", Name.ExportValue(Export)) Call XmlDoc.AddField("SEmail", SEmail.ExportValue(Export)) Call XmlDoc.AddField("zEmail", zEmail.ExportValue(Export)) Call XmlDoc.AddField("Password", Password.ExportValue(Export)) Call XmlDoc.AddField("Mobile", Mobile.ExportValue(Export)) Call XmlDoc.AddField("Gender", Gender.ExportValue(Export)) Call XmlDoc.AddField("Department", Department.ExportValue(Export)) Call XmlDoc.AddField("Docs", Docs.Upload.DbValue) Call XmlDoc.AddField("Agree", Agree.ExportValue(Export)) End If End If Recordset.MoveNext Loop End Sub ' Export data in HTML/CSV/Word/Excel/Email format Public Sub ExportDocument(Doc, Recordset, StartRec, StopRec, ExportPageType) If ew_Empty(Recordset) Or ew_Empty(Doc) Then Exit Sub End If If Not Doc.ExportCustom Then ' Write header Call Doc.ExportTableHeader If Doc.Horizontal Then ' Horizontal format, write header Call Doc.BeginExportRow(0) If ExportPageType = "view" Then If ID.Exportable Then Call Doc.ExportCaption(ID) If Name.Exportable Then Call Doc.ExportCaption(Name) If SEmail.Exportable Then Call Doc.ExportCaption(SEmail) If zEmail.Exportable Then Call Doc.ExportCaption(zEmail) If Password.Exportable Then Call Doc.ExportCaption(Password) If Mobile.Exportable Then Call Doc.ExportCaption(Mobile) If Gender.Exportable Then Call Doc.ExportCaption(Gender) If Department.Exportable Then Call Doc.ExportCaption(Department) If Grievance_1.Exportable Then Call Doc.ExportCaption(Grievance_1) If Docs.Exportable Then Call Doc.ExportCaption(Docs) If Agree.Exportable Then Call Doc.ExportCaption(Agree) Else If ID.Exportable Then Call Doc.ExportCaption(ID) If Name.Exportable Then Call Doc.ExportCaption(Name) If SEmail.Exportable Then Call Doc.ExportCaption(SEmail) If zEmail.Exportable Then Call Doc.ExportCaption(zEmail) If Password.Exportable Then Call Doc.ExportCaption(Password) If Mobile.Exportable Then Call Doc.ExportCaption(Mobile) If Gender.Exportable Then Call Doc.ExportCaption(Gender) If Department.Exportable Then Call Doc.ExportCaption(Department) If Docs.Exportable Then Call Doc.ExportCaption(Docs) If Agree.Exportable Then Call Doc.ExportCaption(Agree) End If Call Doc.EndExportRow(0) End If End If ' Move to first record Dim RecCnt, RowCnt RecCnt = StartRec - 1 If Not Recordset.EOF Then ' Already positioned at first record, no need to move 'Recordset.MoveFirst 'If StartRec > 1 Then Recordset.Move(StartRec - 1) End If Do While Not Recordset.EOF And CLng(RecCnt) < CLng(StopRec) RecCnt = RecCnt + 1 If CLng(RecCnt) >= CLng(StartRec) Then RowCnt = CLng(RecCnt) - CLng(StartRec) + 1 ' Page break If ExportPageBreakCount > 0 Then If RowCnt > 1 And ((RowCnt - 1) Mod ExportPageBreakCount = 0) Then Call Doc.ExportPageBreak End If End If Call LoadListRowValues(Recordset) ' Render row RowType = EW_ROWTYPE_VIEW ' Render view Call ResetAttrs Call RenderListRow If Not Doc.ExportCustom Then Call Doc.BeginExportRow(RowCnt) If ExportPageType = "view" Then If ID.Exportable Then Call Doc.ExportField(ID) If Name.Exportable Then Call Doc.ExportField(Name) If SEmail.Exportable Then Call Doc.ExportField(SEmail) If zEmail.Exportable Then Call Doc.ExportField(zEmail) If Password.Exportable Then Call Doc.ExportField(Password) If Mobile.Exportable Then Call Doc.ExportField(Mobile) If Gender.Exportable Then Call Doc.ExportField(Gender) If Department.Exportable Then Call Doc.ExportField(Department) If Grievance_1.Exportable Then Call Doc.ExportField(Grievance_1) If Docs.Exportable Then Call Doc.ExportField(Docs) If Agree.Exportable Then Call Doc.ExportField(Agree) Else If ID.Exportable Then Call Doc.ExportField(ID) If Name.Exportable Then Call Doc.ExportField(Name) If SEmail.Exportable Then Call Doc.ExportField(SEmail) If zEmail.Exportable Then Call Doc.ExportField(zEmail) If Password.Exportable Then Call Doc.ExportField(Password) If Mobile.Exportable Then Call Doc.ExportField(Mobile) If Gender.Exportable Then Call Doc.ExportField(Gender) If Department.Exportable Then Call Doc.ExportField(Department) If Docs.Exportable Then Call Doc.ExportField(Docs) If Agree.Exportable Then Call Doc.ExportField(Agree) End If Call Doc.EndExportRow(RowCnt) End If End If ' Call Row Export server event If Doc.ExportCustom And ew_NotEmpty(Page) Then ' ASP Call Page.Row_Export(Recordset) End If Recordset.MoveNext Loop If Not Doc.ExportCustom Then Call Doc.ExportTableFooter End If End Sub Public Function ApplyUserIDFilters(Filter) ' Add user id filter Dim sFilter sFilter = Filter ApplyUserIDFilters = sFilter End Function ' Check if User ID security allows view all Dim UserIDAllowSecurity Function UserIDAllow(id) Dim allow allow = EW_USER_ID_ALLOW Select Case id Case "add", "copy", "gridadd", "register", "addopt" UserIDAllow = ((allow And EW_ALLOW_ADD) = EW_ALLOW_ADD) Case "edit", "gridedit", "update", "changepwd", "forgotpwd" UserIDAllow = ((allow And EW_ALLOW_EDIT) = EW_ALLOW_EDIT) Case "delete" UserIDAllow = ((allow And EW_ALLOW_DELETE) = EW_ALLOW_DELETE) Case "view" UserIDAllow = ((allow And EW_ALLOW_VIEW) = EW_ALLOW_VIEW) Case "search" UserIDAllow = ((allow And EW_ALLOW_SEARCH) = EW_ALLOW_SEARCH) Case Else UserIDAllow = ((allow And EW_ALLOW_LIST) = EW_ALLOW_LIST) End Select End Function ' Get auto fill value Public Function GetAutoFill(id, val) Dim cnn, rs, rsArr, str, i, j, rowcnt rowcnt = 0 ' Output If IsArray(rsArr) And rowcnt > 0 Then For j = 0 To UBound(rsArr, 2) For i = 0 To UBound(rsArr, 1) str = rsArr(i, j) & "" If Request.Form("keepCRLF").Count > 0 Then str = Replace(str, vbCr, "\\r") str = Replace(str, vbLf, "\\n") Else str = Replace(str, vbCr, " ") str = Replace(str, vbLf, " ") End If rsArr(i, j) = str Next Next GetAutoFill = ew_ArrayToJson(rsArr) Else GetAutoFill = "" End If End Function ' Send register email Function SendRegisterEmail(row) Dim Email, Args, bEmailSent Set Email = PrepareRegisterEmail(row, "") Set Args = Server.CreateObject("Scripting.Dictionary") Args.Add "rs", row bEmailSent = False If Email_Sending(Email, Args) Then ' NOTE: use Email_Sending server event of user table bEmailSent = Email.Send() End If SendRegisterEmail = bEmailSent End Function ' Prepare register email Function PrepareRegisterEmail(row, langid) Dim Email, sReceiverEmail, sBccEmail Dim sLoginID, sPassword, sActivateLink, sToken Set Email = New cEmail Call Email.Load(EW_EMAIL_REGISTER_TEMPLATE, langid) If IsNull(row) Then sReceiverEmail = zEmail.CurrentValue Else sReceiverEmail = row("Email") End If If sReceiverEmail = "" Then ' Send to recipient directly sReceiverEmail = EW_RECIPIENT_EMAIL sBccEmail = "" Else ' Bcc recipient sBccEmail = EW_RECIPIENT_EMAIL End If Call Email.ReplaceSender(EW_SENDER_EMAIL) ' Replace Sender Call Email.ReplaceRecipient(sReceiverEmail) ' Replace Recipient If sBccEmail <> "" Then Call Email.AddBcc(sBccEmail) ' Add Bcc Call Email.ReplaceContent("<!--FieldCaption_ID-->", ID.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--ID-->", CStr(ID.FormValue)) Else Call Email.ReplaceContent("<!--ID-->", row("ID")) End If Call Email.ReplaceContent("<!--FieldCaption_Name-->", Name.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Name-->", CStr(Name.FormValue)) Else Call Email.ReplaceContent("<!--Name-->", row("Name")) End If Call Email.ReplaceContent("<!--FieldCaption_SEmail-->", SEmail.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--SEmail-->", CStr(SEmail.FormValue)) Else Call Email.ReplaceContent("<!--SEmail-->", row("SEmail")) End If Call Email.ReplaceContent("<!--FieldCaption_Email-->", zEmail.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Email-->", CStr(zEmail.FormValue)) Else Call Email.ReplaceContent("<!--Email-->", row("Email")) End If Call Email.ReplaceContent("<!--FieldCaption_Password-->", Password.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Password-->", CStr(Password.FormValue)) Else Call Email.ReplaceContent("<!--Password-->", row("Password")) End If Call Email.ReplaceContent("<!--FieldCaption_Mobile-->", Mobile.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Mobile-->", CStr(Mobile.FormValue)) Else Call Email.ReplaceContent("<!--Mobile-->", row("Mobile")) End If Call Email.ReplaceContent("<!--FieldCaption_Gender-->", Gender.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Gender-->", CStr(Gender.FormValue)) Else Call Email.ReplaceContent("<!--Gender-->", row("Gender")) End If Call Email.ReplaceContent("<!--FieldCaption_Department-->", Department.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Department-->", CStr(Department.FormValue)) Else Call Email.ReplaceContent("<!--Department-->", row("Department")) End If Call Email.ReplaceContent("<!--FieldCaption_Grievance-->", Grievance_1.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Grievance-->", CStr(Grievance_1.FormValue)) Else Call Email.ReplaceContent("<!--Grievance-->", row("Grievance")) End If Call Email.ReplaceContent("<!--FieldCaption_Docs-->", Docs.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Docs-->", CStr(Docs.FormValue)) Else Call Email.ReplaceContent("<!--Docs-->", row("Docs")) End If Call Email.ReplaceContent("<!--FieldCaption_Agree-->", Agree.FldCaption) If IsNull(row) Then Call Email.ReplaceContent("<!--Agree-->", CStr(Agree.FormValue)) Else Call Email.ReplaceContent("<!--Agree-->", row("Agree")) End If Email.Content = ew_RegExReplace("<!--\s*register_activate_link_begin[\s\S]*?-->[\s\S]*?<!--\s*register_activate_link_end[\s\S]*?-->", Email.Content, "") ' Remove activate link block Set PrepareRegisterEmail = Email End Function Dim CurrentAction ' Current action Dim LastAction ' Last action Dim CurrentMode ' Current mode Dim UpdateConflict ' Update conflict Dim EventName ' Event name Dim EventCancelled ' Event cancelled Dim CancelMessage ' Cancel message Dim AllowAddDeleteRow ' Allow add/delete row Dim ValidateKey ' Validate key Dim DetailAdd ' Allow detail add Dim DetailEdit ' Allow detail edit Dim DetailView ' Allow detail view Dim ShowMultipleDetails ' Show multiple details Dim GridAddRowCount ' Grid add row count ' Check current action ' Add Public Function IsAdd() IsAdd = (CurrentAction = "add") End Function ' Copy Public Function IsCopy() IsCopy = (CurrentAction = "copy" Or CurrentAction = "C") End Function ' Edit Public Function IsEdit() IsEdit = (CurrentAction = "edit") End Function ' Delete Public Function IsDelete() IsDelete = (CurrentAction = "D") End Function ' Confirm Public Function IsConfirm() IsConfirm = (CurrentAction = "F") End Function ' Overwrite Public Function IsOverwrite() IsOverwrite = (CurrentAction = "overwrite") End Function ' Cancel Public Function IsCancel() IsCancel = (CurrentAction = "cancel") End Function ' Grid add Public Function IsGridAdd() IsGridAdd = (CurrentAction = "gridadd") End Function ' Grid edit Public Function IsGridEdit() IsGridEdit = (CurrentAction = "gridedit") End Function ' Add/Copy/Edit/GridAdd/GridEdit Public Function IsAddOrEdit() IsAddOrEdit = IsAdd() Or IsCopy() Or IsEdit() Or IsGridAdd() Or IsGridEdit() End Function ' Insert Public Function IsInsert() IsInsert = (CurrentAction = "insert" Or CurrentAction = "A") End Function ' Update Public Function IsUpdate() IsUpdate = (CurrentAction = "update" Or CurrentAction = "U") End Function ' Grid update Public Function IsGridUpdate() IsGridUpdate = (CurrentAction = "gridupdate") End Function ' Grid insert Public Function IsGridInsert() IsGridInsert = (CurrentAction = "gridinsert") End Function ' Grid overwrite Public Function IsGridOverwrite() IsGridOverwrite = (CurrentAction = "gridoverwrite") End Function ' Check last action ' Cancelled Public Function IsCancelled() IsCancelled = (LastAction = "cancel" And CurrentAction = "") End Function ' Inline inserted Public Function IsInlineInserted() IsInlineInserted = (LastAction = "insert" And CurrentAction = "") End Function ' Inline updated Public Function IsInlineUpdated() IsInlineUpdated = (LastAction = "update" And CurrentAction = "") End Function ' Grid updated Public Function IsGridUpdated() IsGridUpdated = (LastAction = "gridupdate" And CurrentAction = "") End Function ' Grid inserted Public Function IsGridInserted() IsGridInserted = (LastAction = "gridinsert" And CurrentAction = "") End Function ' Row Type Private m_RowType Public Property Get RowType RowType = m_RowType End Property Public Property Let RowType(v) m_RowType = v End Property Dim CssClass ' CSS class Dim CssStyle' CSS style Dim RowAttrs ' Row attributes ' Row Styles Public Property Get RowStyles Dim sAtt, Value Dim sStyle, sClass sAtt = "" sStyle = CssStyle If RowAttrs.Exists("style") Then Value = RowAttrs("style") If Trim(Value) <> "" Then sStyle = sStyle & " " & Value End If End If sClass = CssClass If RowAttrs.Exists("class") Then Value = RowAttrs("class") If Trim(Value) <> "" Then sClass = sClass & " " & Value End If End If If Trim(sStyle) <> "" Then sAtt = sAtt & " style=""" & Trim(sStyle) & """" End If If Trim(sClass) <> "" Then sAtt = sAtt & " class=""" & Trim(sClass) & """" End If RowStyles = sAtt End Property ' Row Attribute Public Property Get RowAttributes Dim sAtt, dict, sStyle, sClass If Export = "" Then Set dict = Dictionary() sStyle = Trim(CssStyle&"") If sStyle <> "" Then dict.Add "style", sStyle End If sClass = Trim(CssClass&"") If sClass <> "" Then dict.Add "class", sClass End If sAtt = sAtt & RowAttrs.ToString(dict) Set dict = Nothing Else sAtt = RowStyles End If RowAttributes = sAtt End Property ' Export Dim Export Dim CustomExport ' Export All Dim ExportAll Dim ExportPageBreakCount ' Page break per every n record (PDF only) Dim ExportPageOrientation ' Page orientation (PDF only) Dim ExportPageSize ' Page size (PDF only) ' Send Email Dim SendEmail ' ' Field objects ' ' Field (ID) Private m_ID Public Property Get ID If ew_Empty(m_ID) Then Set m_ID = NewFldObj("Grievance", "Grievance", "x_ID", "ID", "ID", "ID", 3, 0, "ID", False, False, False, "FORMATTED TEXT", "NO") m_ID.Sortable = True ' Allow sort m_ID.FldDefaultErrMsg = Language.Phrase("IncorrectInteger") End If Set ID = m_ID End Property ' Field (Name) Private m_Name Public Property Get Name If ew_Empty(m_Name) Then Set m_Name = NewFldObj("Grievance", "Grievance", "x_Name", "Name", "Name", "Name", 202, 0, "Name", False, False, False, "FORMATTED TEXT", "TEXT") m_Name.Sortable = True ' Allow sort End If Set Name = m_Name End Property ' Field (SEmail) Private m_SEmail Public Property Get SEmail If ew_Empty(m_SEmail) Then Set m_SEmail = NewFldObj("Grievance", "Grievance", "x_SEmail", "SEmail", "SEmail", "SEmail", 202, 0, "SEmail", False, False, False, "FORMATTED TEXT", "TEXT") m_SEmail.Sortable = True ' Allow sort End If Set SEmail = m_SEmail End Property ' Field (Email) Private m_zEmail Public Property Get zEmail If ew_Empty(m_zEmail) Then Set m_zEmail = NewFldObj("Grievance", "Grievance", "x_zEmail", "Email", "Email", "Email", 202, 0, "Email", False, False, False, "FORMATTED TEXT", "TEXT") m_zEmail.Sortable = True ' Allow sort m_zEmail.FldDefaultErrMsg = Language.Phrase("IncorrectEmail") End If Set zEmail = m_zEmail End Property ' Field (Password) Private m_Password Public Property Get Password If ew_Empty(m_Password) Then Set m_Password = NewFldObj("Grievance", "Grievance", "x_Password", "Password", "Password", "Password", 202, 0, "Password", False, False, False, "FORMATTED TEXT", "TEXT") m_Password.Sortable = True ' Allow sort End If Set Password = m_Password End Property ' Field (Mobile) Private m_Mobile Public Property Get Mobile If ew_Empty(m_Mobile) Then Set m_Mobile = NewFldObj("Grievance", "Grievance", "x_Mobile", "Mobile", "Mobile", "Mobile", 20, 0, "Mobile", False, False, False, "FORMATTED TEXT", "TEXT") m_Mobile.Sortable = True ' Allow sort m_Mobile.FldDefaultErrMsg = Language.Phrase("IncorrectInteger") End If Set Mobile = m_Mobile End Property ' Field (Gender) Private m_Gender Public Property Get Gender If ew_Empty(m_Gender) Then Set m_Gender = NewFldObj("Grievance", "Grievance", "x_Gender", "Gender", "Gender", "Gender", 202, 0, "Gender", False, False, False, "FORMATTED TEXT", "RADIO") m_Gender.Sortable = True ' Allow sort m_Gender.OptionCount = 2 End If Set Gender = m_Gender End Property ' Field (Department) Private m_Department Public Property Get Department If ew_Empty(m_Department) Then Set m_Department = NewFldObj("Grievance", "Grievance", "x_Department", "Department", "Department", "Department", 202, 0, "Department", False, False, False, "FORMATTED TEXT", "TEXT") m_Department.Sortable = True ' Allow sort End If Set Department = m_Department End Property ' Field (Grievance) Private m_Grievance_1 Public Property Get Grievance_1 If ew_Empty(m_Grievance_1) Then Set m_Grievance_1 = NewFldObj("Grievance", "Grievance", "x_Grievance_1", "Grievance", "Grievance", "Grievance", 203, 0, "Grievance", False, False, False, "FORMATTED TEXT", "TEXTAREA") m_Grievance_1.Sortable = True ' Allow sort End If Set Grievance_1 = m_Grievance_1 End Property ' Field (Docs) Private m_Docs Public Property Get Docs If ew_Empty(m_Docs) Then Set m_Docs = NewFldObj("Grievance", "Grievance", "x_Docs", "Docs", "Docs", "Docs", 202, 0, "Docs", False, False, False, "FORMATTED TEXT", "FILE") m_Docs.Sortable = True ' Allow sort m_Docs.UploadPath = EW_UPLOAD_DEST_PATH End If Set Docs = m_Docs End Property ' Field (Agree) Private m_Agree Public Property Get Agree If ew_Empty(m_Agree) Then Set m_Agree = NewFldObj("Grievance", "Grievance", "x_Agree", "Agree", "Agree", "Agree", 202, 0, "Agree", False, False, False, "FORMATTED TEXT", "RADIO") m_Agree.Sortable = True ' Allow sort m_Agree.OptionCount = 1 End If Set Agree = m_Agree End Property ' Get field object by name Public Function GetField(Name) Set GetField = Fields.Get(Name) End Function ' Get field object by parm Public Function GetFieldByParm(Parm) Dim keys, key keys = Fields.Keys() For Each key In keys If Fields.Get(key).FldParm = Parm Then Set GetFieldByParm = Fields.Get(key) Exit Function End If Next Set GetFieldByParm = Nothing End Function ' Create new field object Private Function NewFldObj(TblVar, TblName, FldVar, FldName, FldExpression, FldBasicSearchExpression, FldType, FldDtFormat, FldVirtualExp, FldVirtual, FldForceSelect, FldVirtualSearch, FldViewTag, FldHtmlTag) Dim fld Set fld = New cField fld.TblVar = TblVar fld.TblName = TblName fld.FldVar = FldVar fld.FldName = FldName fld.FldExpression = FldExpression fld.FldBasicSearchExpression = FldBasicSearchExpression fld.FldType = FldType fld.FldDataType = ew_FieldDataType(FldType) fld.FldDateTimeFormat = FldDtFormat fld.FldVirtualExpression = FldVirtualExp fld.FldIsVirtual = FldVirtual fld.FldForceSelection = FldForceSelect fld.FldVirtualSearch = FldVirtualSearch fld.FldViewTag = FldViewTag fld.AdvancedSearch.TblVar = TblVar fld.AdvancedSearch.FldVar = FldVar fld.FldHtmlTag = FldHtmlTag Set NewFldObj = fld End Function ' Table level events ' Recordset Selecting event Sub Recordset_Selecting(filter) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here End Sub ' Recordset Selected event Sub Recordset_Selected(rs) 'Response.Write "Recordset Selected" End Sub ' Recordset Search Validated event Sub Recordset_SearchValidated() If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here End Sub ' Recordset Searching event Sub Recordset_Searching(filter) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here End Sub ' Row_Selecting event Sub Row_Selecting(filter) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here End Sub ' Row Selected event Sub Row_Selected(rs) 'Response.Write "Row Selected" End Sub ' Row Inserting event Function Row_Inserting(rsold, rsnew) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here ' To cancel, set return value to False Row_Inserting = True End Function ' Row Inserted event Sub Row_Inserted(rsold, rsnew) ' Response.Write "Row Inserted" End Sub ' Row Updating event Function Row_Updating(rsold, rsnew) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here ' To cancel, set return value to False Row_Updating = True End Function ' Row Updated event Sub Row_Updated(rsold, rsnew) ' Response.Write "Row Updated" End Sub ' Row Update Conflict event Function Row_UpdateConflict(rsold, rsnew) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here ' To ignore conflict, set return value to False Row_UpdateConflict = True End Function ' Grid Inserting event Function Grid_Inserting() ' Enter your code here ' To reject grid insert, set return value to False Grid_Inserting = True End Function ' Grid Inserted event Sub Grid_Inserted(rsnew) 'Response.Write "Grid Inserted" End sub ' Grid Updating event Function Grid_Updating(rsold) ' Enter your code here ' To reject grid update, set return value to False Grid_Updating = True End Function ' Grid Updated event Sub Grid_Updated(rsold, rsnew) 'Response.Write "Grid Updated" End Sub ' Row Deleting event Function Row_Deleting(rs) If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here ' To cancel, set return value to False Row_Deleting = True End Function ' Row Deleted event Sub Row_Deleted(rs) ' Response.Write "Row Deleted" End Sub ' Email Sending event Function Email_Sending(Email, Args) 'Response.Write Email.AsString 'Response.Write "Keys of Args: " & Join(Args.Keys, ", ") 'Response.End Email_Sending = True End Function ' Lookup Selecting event Sub Lookup_Selecting(fld, filter) ' Uncomment to below code view the SQL and the filters ' Response.Write fld.LookupFilters.ToJson() End Sub ' Row Rendering event Sub Row_Rendering() If Not EW_DEBUG_ENABLED Then On Error Resume Next ' Enter your code here End Sub ' Row Rendered event Sub Row_Rendered() ' To view properties of field class, use: ' Response.Write <FieldName>.AsString() End Sub ' User ID Filtering event Sub UserID_Filtering(filter) ' Enter your code here End Sub ' Class terminate Private Sub Class_Terminate() If ew_NotEmpty(m_ID) Then Set m_ID = Nothing If ew_NotEmpty(m_Name) Then Set m_Name = Nothing If ew_NotEmpty(m_SEmail) Then Set m_SEmail = Nothing If ew_NotEmpty(m_zEmail) Then Set m_zEmail = Nothing If ew_NotEmpty(m_Password) Then Set m_Password = Nothing If ew_NotEmpty(m_Mobile) Then Set m_Mobile = Nothing If ew_NotEmpty(m_Gender) Then Set m_Gender = Nothing If ew_NotEmpty(m_Department) Then Set m_Department = Nothing If ew_NotEmpty(m_Grievance_1) Then Set m_Grievance_1 = Nothing If ew_NotEmpty(m_Docs) Then Set m_Docs = Nothing If ew_NotEmpty(m_Agree) Then Set m_Agree = Nothing Set RowAttrs = Nothing End Sub End Class %>