ASP simulation MVC pattern programming

Source: Internet
Author: User

We all know Java is the most popular MVC model of the programming, if you do not know the concept of MVC, you can go to the Internet search, you should immediately find more than n data. After the launch of PHP5, also began to use the MVC pattern development, it seems that MVC does have a great appeal!

I am in peacetime development of ASP projects, but also learn from the Java development model, although the implementation is not very good, but also make the code structure clear a lot, greatly facilitate the art modification program!

Here is my code, the specific description to see the comments.

The main implementation of the program is the operation of the backend administrator: Add, delete, modify

Divided into two procedures, adminusers_class.asp,adminusers_gl.asp

Equivalent to Java force a servlet, a bean! So there's no full implementation of MVC, just a mock up!

The adminusers_class.asp code is as follows:

<%
REM ***************** General website Management System ***********************************
REM Page function: admin class for Web admin
REM @author Cai Xiaoliang
REM @version 1.0
REM @date 2005-2-22
%>
<!--#include file= "conn.asp"-->
<%
' Admin Management class
Class ADMINUSERSGL
Dim ASO
Private Adminuser_name
Private Adminuser_password
Private admingroup_id
Private Adminuser_isshow
Private Adminuser_selfconfig
Private Adminuser_realname
' Constructor begins
Private Sub Class_Initialize
Set aso=server.createobject ("Adodb.recordset")
End Sub
' Destructor begins
Private Sub Class_Terminate
Err.Clear
Set aso=nothing
End Sub
' Add admin
Public Function Adminusers_add (adminuser_name,adminuser_password,admingroup_id,adminuser_realname,adminuser_ Selfconfig,adminuser_isshow,adminuser_language)
Sql= "Select Adminuser_name from ce_adminusers where Adminuser_name= '" "&adminuser_name&" "
ASO. Open sql,conn,1,3
If ASO. Recordcount<>0 Then
Response.Redirect ("Messages.asp?mess_name=data_add_failure&back_page=adminusers_gl.asp?action=add")
End If
If ASO. Recordcount=0 Then
ASO. Close
sql= INSERT INTO Ce_adminusers (adminuser_name,adminuser_password,admingroup_id,adminuser_realname,adminuser_ Selfconfig,adminuser_isshow,adminuser_language) VALUES (' &adminuser_name& "', '" &adminuser_password & "," &admingroup_id& ", '" &adminuser_realname& "', '" &adminuser_selfconfig& ", '" & adminuser_isshow& "', '" &adminuser_language& ")"
Response.Write (SQL)
ASO. Open sql,conn,1,3
Response.Redirect ("Messages.asp?mess_name=add_success&back_page=adminusers_gl.asp?action=add")
ASO. Close
End If
End Function
' Get an admin message
Public Function adminusers_xx (adminuser_id)
Sql= "Select Adminuser_id,adminuser_name,adminuser_password,admingroup_id,adminuser_isshow,adminuser_selfconfig, Adminuser_language,adminuser_realname from Ce_adminusers where adminuser_id= "&adminuser_id
ASO. Open sql,conn,1,3
If ASO. Recordcount=0 Then
Response.Redirect ("Messages.asp?mess_name=get_xx_failure&back_page=adminusers_gl.asp?action=list")
Else
Adminuser_name=aso ("Adminuser_name")
Adminuser_password=aso ("Adminuser_password")
Admingroup_id=aso ("admingroup_id")
Adminuser_isshow=aso ("Adminuser_isshow")
Adminuser_selfconfig=aso ("Adminuser_selfconfig")
Adminuser_language=aso ("Adminuser_language")
Adminuser_realname=aso ("Adminuser_realname")
End If
Aso.close
End Function
' Modify an Administrator
Public Function Adminusers_modideal (adminuser_id,adminuser_name,adminuser_password,admingroup_id,adminuser_ Isshow,adminuser_selfconfig,adminuser_language,adminuser_realname)
sql= "Update ce_adminusers set adminuser_name= '" &adminuser_name& "', adminuser_password= '" &adminuser_ password& "', admingroup_id=" &admingroup_id& ", adminuser_isshow= ' &adminuser_isshow&" ', Adminuser_selfconfig= ' &adminuser_selfconfig& ', adminuser_language= ' &adminuser_language& ', Adminuser_realname= ' "&adminuser_realname&" ' where adminuser_id= "&adminuser_id
Response. Write (SQL)
ASO. Open sql,conn,1,3
Response.Redirect ("Messages.asp?mess_name=modify_success&back_page=adminusers_gl.asp?action=list")
ASO. Close
End Function
' Get the admin list
Public Function adminusers_list ()
Sql= "Select Ce_admingroups.admingroup_name, Ce_adminusers.adminuser_id,ce_adminusers.adminuser_name, Ce_ Adminusers.adminuser_logintimes, ce_adminusers.adminuser_isshow from ce_admingroups INNER JOIN ce_adminusers on Ce_ admingroups.admingroup_id = ce_adminusers.admingroup_id "
ASO. Open sql,conn,1,3
While not aso.eof
If ASO ("adminuser_isshow") = "Y" Then
show= "Yes"
Else
Show= "No"
End If
Response.Write "<tr><td align=right class=td1 width=27% height=25><p align=center>" &ASO (" Adminuser_name ") &" </td><td width=30% align=right class=td1><div align=center> "&ASO (" Admingroup_name ") &" </div></td><td width=13% align=right class=td1><div align=center> " &aso ("Adminuser_logintimes") & "</div></td><td width=10% height=25 class=td2><div Align =center> "&show&" </div></td><td width=10% class=td2><div align=center><a href =adminusers_gl.asp?action=modi&adminuser_id= "&aso (" adminuser_id ") &" > Modify </a></div> &LT;/TD&GT;&LT;TD width=10% class=td2><div align=center><a href=adminusers_gl.asp?action=del& Adminuser_id= "&aso (" adminuser_id ") &" > Delete </a></div></td></tr> "
  
Aso.movenext
Wend
ASO. Close
End Function
' Remove admin
Public Function Adminusers_del (adminuser_id)
Sql= "Delete from ce_adminusers where adminuser_id=" &adminuser_id
ASO. Open sql,conn,1,3
Response.Redirect ("Messages.asp?mess_name=del_success&back_page=adminusers_gl.asp?action=list")
ASO. Close
End Function
' Get a list of all admins groups
Public Function get_admingroups ()
Sql= "Select Admingroup_id,admingroup_name from ce_admingroups where admingroup_language= '" &LANGUAGE& " by admingroup_id ASC "
ASO. Open sql,conn,1,3
Response. Write ("&nbsp;<select name=admingroup_id>")
While not aso.eof
Response. Write ("<option value=" &aso ("admingroup_id") & ">" &aso ("Admingroup_name") & "</option>")
Aso.movenext
Wend
Response. Write ("</select>")
ASO. Close
End Function
' Get a list of all the Administrators groups and select the current Administrators group
Public Function get_admingroups_s ()
Sql= "Select Admingroup_id,admingroup_name from ce_admingroups where admingroup_language= '" &LANGUAGE& " by admingroup_id ASC "
ASO. Open sql,conn,1,3
Response. Write ("&nbsp;<select name=admingroup_id>")
While not aso.eof
If ASO ("admingroup_id") =admingroup_id Then
S= "Selected"
Else
S= ""
End If
Response. Write ("<option value=" &aso ("admingroup_id") & "&s&" > "&aso (" Admingroup_name ") &" < /option> ")
Aso.movenext
Wend
Response. Write ("</select>")
ASO. Close
End Function
' Common properties for external programs to call
Public Property Get Auname
Auname = Adminuser_name
End Property
Public Property Get Aupassword
Aupassword = Adminuser_password
End Property
Public Property Get Augroupid
Augroupid = admingroup_id
End Property
Public Property Get Auisshow
Auisshow = Adminuser_isshow
End Property
Public Property Get Auselfconfig
Auselfconfig = Adminuser_selfconfig
End Property
Public Property Get Aurealname
Aurealname = Adminuser_realname
End Property
End Class
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.