usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingWebhelper;namespaceaspxwebform{/// <summary> ///Delete Class/// </summary> Public class_02del:ihttphandler { Public voidProcessRequest (HttpContext context) {context. Response.ContentType="text/html"; //1. Get the class ID that the browser get passed over to delete stringStrid = context. request.querystring["ID"]; //2. Verify that the ID is a numeric value if(Commonhelper.isnum (Strid))//Validation by { //3. Delete the corresponding class data if(NewBLL. Classes (). Updatedel (Strid)) {//Delete succeededCommonhelper.writejs ("Delete Success! ","01classeslist.aspx"); } Else { //Delete FailedCommonhelper.writejs ("Delete failed! If you are a beauty, please contact the Administrator ~~~qq:111111","01classeslist.aspx"); } } Else {//4. Verification Failure//through the output JS first let the browser user see the error message, and then directly through the JS control browser to jump to the list page (again request the server's list page)Context. Response.Write ("<script>alert (' Your parameters are wrong! What do you mean ~~! '); window.location= ' 01classeslist.aspx ';</script>"); } } Public BOOLisreusable {Get { return false; } } }}
Bll
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacebll{/// <summary> ///Author: Liuhaitao///Description: Business Layer-the business operations class for the classes table. ///time: 2013/2/4 9:35:00/// </summary> Public classClasses {Private ReadOnlyDAL. Classes dal =NewDAL. Classes (); #region04. Soft Delete + int Updatedel (string IDs)/// <summary> ///Soft Delete (sets the delete flag to true)/// </summary>typically: 0 for false,1 on behalf of True/// <param name= "IDs" >the IDs to be soft deleted</param> /// <returns>Soft Delete succeeded or not</returns> Public BOOLUpdatedel (stringIDs) { returnDal. Updatedel (IDs,true) >0; } #endregion #region05. Physically Delete +int Del (string IDs)/// <summary> ///Physical Delete (sets the delete flag to true)/// </summary> /// <param name= "IDs" >the IDs to be deleted</param> /// <returns>Delete succeeded or not</returns> Public BOOLDel (stringIDs) { returnDal. Del (IDS) >0; } #endregion
}
}
DAL
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data;usingSystem.Data.SqlClient;namespacedal{/// <summary> ///Author:jameszou///Description: Data Layer-The entity class of classes. ///creation time: 2013/2/4 9:33:40/// </summary> Public classClasses {#region01. Modify the soft-delete flag/// <summary> ///Modify the soft-delete flag/// </summary> /// <param name= "IDs" >to modify the ID number of the soft-delete flag (1,2,5)</param> /// <param name= "Isdel" >to change the delete flag to True/false</param> /// <returns>number of rows affected</returns> Public intUpdatedel (stringIdsBOOLIsdel) {StringBuilder strSQL=NewStringBuilder (); Strsql.append ("exec (' Update Classes set cisdel= '"+ isdel.tostring () +"" where CID in (' [email protected]+ ') ')"); SqlParameter para=NewSqlParameter ("@ids", IDS); returnDbhelpersql.excutenonquery (strsql.tostring (), para); } #endregion #region01.2 single-Modified soft-deletion flag/// <summary> ///single Modify soft-delete flag/// </summary> /// <param name= "Idint" >to modify the ID number of a soft-delete flag</param> /// <param name= "Isdel" >to change the delete flag to True/false</param> /// <returns>number of rows affected</returns> Public intUpdatedel (intIdint,BOOLIsdel) { stringstrSQL ="Update Classes set cisdel= '"+ isdel.tostring () +"' WHERE CID = @id"; SqlParameter para=NewSqlParameter ("@id", Idint); returndbhelpersql.excutenonquery (strSQL, para); } #endregion #region02. Performing a physical delete +int Del (string IDs)/// <summary> ///Performing physical Deletes/// </summary> /// <param name= "IDs" >ID numbers to delete (1,2,5)</param> /// <returns>number of rows affected</returns> Public intDel (stringIDs) {StringBuilder strSQL=NewStringBuilder (); Strsql.append ("exec (' delete Classes where CID in (' [email protected]+ ') ')"); SqlParameter para=NewSqlParameter ("@ids", IDS); returnDbhelpersql.excutenonquery (strsql.tostring (), para); } #endregion #region02.2 Single Physical deletion/// <summary> ///Single Physical Delete/// </summary> /// <param name= "Idint" >the ID number to delete</param> /// <returns>number of rows affected</returns> Public intDel (intidint) { stringstrSQL ="Delete Classes where CID = @id"; SqlParameter para=NewSqlParameter ("@id", Idint); returndbhelpersql.excutenonquery (strSQL, para); } #endregion
}
}
02DEL.ASHX (delete Class)