EASYUI+MVC+WCF Delete Information--examination system

Source: Internet
Author: User

Go directly into the topic, the main want to write is a bulk delete, how to get the corresponding ID from the DataGrid in the foreground and then upload to the background for bulk deletion.

Front desk DataGrid page: Painted with Easyui

The specific code:

In front of JS to write:

//Delete $ ("#btn_Remove"). Unbind ("click"). Click (function Destroyexaminee () {//    Gets the selected number of rows var rows = $ (' #dg '). DataGrid (' Getselections '); Determines whether to select the row if (!rows | | rows.length = = 0) {$.messager.alert (' reminder ', ' Please select at least one row of data!        ', ' Info ');    Return    }//Get table select row var Strid; Loop to commit delete parameter assignment (candidate ID) $.each (rows, function (i, n) {if (i = = 0) {Strid = "examineeid=" + N.examineeid        ;        } else {Strid + = "&examineeid=" + N.examineeid;    }                        });        Two confirmation $.messager.confirm (' hint ', ' Do you want to delete the selected data? ', function (r) {if (!r) {return; }//Submit, upload the acquired data to the backend $.ajax ({type: "POST", Async:false, url: "/examinee/dele                Teexaminee ", Data:strid, Success:function (data) {var jsondata = eval (data);            $ (' #dg '). DataGrid (' LoadData ', data);    }        }); });});

The code to be written in the controller of MVC:

        <summary>//Delete candidate information///</summary>//<param name= "IList" ></param&        Gt <returns></returns> public bool Deleteexaminee () {//Capture data from foreground string St            Rexamineeid = request.form["Examineeid"];            Convert captured data to an array of string[] Listenexamineeid = Strexamineeid.split (new char[] {', '});            list<examexamineeexamroomentity> Listexamineeid = new list<examexamineeexamroomentity> (); 3. Store the ID to be deleted to a candidate entity set for (int i = 0; i < Listenexamineeid.count (); i++) {str ing tempstr = listenexamineeid[i].                ToString ();                Listexamineeid.add (New examexamineeexamroomentity ()); Listexamineeid[i].                            Examineeid = TempStr;            }//Call the Delete method of the service tier bool isdeletesuccess = Examineeservice.deleteexamineebyexamineeid (Listexamineeid); return isdeletesuccess;This returns the data ID list collection that is selected in the foreground and can return other data} 

Then there is the WCF service layer, which calls the B-tier method

Here's the B-tier approach.

The underlying frame is already in advance, and the deletion is a fake delete, in order to keep the exam record for international students, just add a deleted identity to the table.

<summary>///delete candidate information (change candidates by candidate ID)--2014-12-16 11:01:52///</summary>//<para        M name= "Listexamineeid" > Candidate ID Entity collection </param>//<returns> Returns whether the deletion succeeded, succeeded to true, failed to false</returns>                        public bool Deleteexamineebyexamineeid (list<examexamineeexamentity> Listexamineeid) {                     try {for (int i = 0; i < Listexamineeid.count; i++) {                     1. Create entity rules to delete candidates examexamineeexamentity Tempexaminee = new Examexamineeexamentity ()                     {isdeleteexamineeexam = 1}; Delete Candidate String guid = Listexamineeid[i].                     Examineeid; This.                 Currentdal.update (tempexaminee, u = U.examineeid = = GUID, "Isdeleteexamineeexam"); }//Save information, return true this.     Dbsession.savechanges ();           return true;            } catch (Exception ex) {//throws exception throw (ex);   }

Through this test system to participate in the project, the deepest feeling is the knowledge you may have learned, but you have no way to apply it to practice, so you just learned, not learn, practice is the hard truth Ah ~ ~

EASYUI+MVC+WCF Delete Information--examination system

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.