ASP simulation MVC pattern programming

Source: Internet
Author: User
Programmers know that the most popular Java is the 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>



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.