Added, deleted, modified, and queried by ASP combined with the jquery easyui framework

Source: Internet
Author: User

$ (Document). Ready (function (){
$ ("# Addpayorder"). linkbutton ({text: "add "});
$ ("# Editpayorder"). linkbutton ({text: "modify "});
$ ("# Delpayorder"). linkbutton ({text: "delete "});
 
 
// Bind the right-click menu
$ ("# Trdata"). BIND ("contextmenu", function (e ){
$ ("# Menu"). menu ("show ",{
Left: E. pagex,
Top: E. Pagey
});
Return false;
});
// Add order
$ ("# Addpayorder"). Click (function (){
// $ ("# W"). Find ("input [type = 'text']"). Val ("");
// Clear all text box values and Text Field Values
$ (": Input"). Each (function (){
If ($ (this). ATTR ("type") = "text" | $ (this). ATTR ("type") = "textarea "){
$ (This). Val ("");
}
})
VaR user = $ ("# huserid"). Val ();
If (user! = ""){
$ ("# Txtuserid"). Val (User );
}
// $ ("# Txtuserid"). removeattr ("disabled ");
Document. getelementbyid ("hiddenaction"). value = "add ";
Openwin ("Add User order ");
$ ('# W'). Window ("open ");
Getprodsubnamebyid ($ ("# selprodid"). Val (); // obtain the product subclass of the selected product
});
// Modify the order
$ ("# Editpayorder"). Click (function (){
// $ ("# W"). Find ("input [type = 'text']"). Val (""); // clear all text box values
$ (": Input"). Each (function (){
If ($ (this). ATTR ("type") = "text" | $ (this). ATTR ("type") = "textarea "){
$ (This). Val ("");
}
});
Document. getelementbyid ("hiddenaction"). value = "edit ";
VaR selecttr = $ ("# hiddenvalue"). Val (); // value the hiddenvalue when you click or double-click a row.
If (selecttr = ""){
Msgbox ("system prompt", "Please select a row for modification first! "," Error ");
} Else {
Openwin ("Modify order ");
$ ('# W'). Window ("open ");
Getpayorderinfobyid (selecttr );
Gettotalmoney (); // calculate the total fee
Getprodsubnamebyid ($ ("# hiddenprodid"). Val (); // obtain the product subclass of the selected product
}
});
 
// Delete the order
$ ("# Delpayorder"). Click (function (){
VaR selecttr = $ ("# hiddenvalue"). Val ();
If (selecttr = ""){
Msgbox ("system prompt", "Please select a row for modification first! "," Error ");
} Else {
$. Messager. Confirm ("system prompt", "Are you sure you want to delete this order? ", Function (r ){
If (r ){
Delete (selecttr );
}
})
}
});
 
// Right-click the menu to delete
$ ("# Menudel"). Click (function (){
VaR selecttr = $ ("# hiddenvalue"). Val ();
If (selecttr = ""){
Msgbox ("system prompt", "Please select a row for modification first! "," Error ");
} Else {
$. Messager. Confirm ("system prompt", "Are you sure you want to delete this order? ", Function (r ){
If (r ){
Delete (selecttr );
}
})
}
});
 
// Right-click the menu to edit
$ ("# Menuedit"). Click (function (){
// $ ("# W"). Find ("input [type = 'text']"). Val (""); // clear all text box values
$ (": Input"). Each (function (){
If ($ (this). ATTR ("type") = "text" | $ (this). ATTR ("type") = "textarea "){
$ (This). Val ("");
}
})
Document. getelementbyid ("hiddenaction"). value = "edit ";
VaR selecttr = $ ("# hiddenvalue"). Val ();
If (selecttr = ""){
Msgbox ("system prompt", "Please select a row for modification first! "," Error ");
} Else {
Openwin ("Modify order ");
$ ('# W'). Window ("open ");
Getpayorderinfobyid (selecttr );
Gettotalmoney (); // calculate the total fee
Getprodsubnamebyid ($ ("# hiddenprodid"). Val (); // obtain the product subclass of the selected product
}
});
 
// Right-click the menu to add an operation
$ ("# Menuadd"). Click (function (){
// $ ("# W"). Find ("input [type = 'text']"). Val ("");
// Clear all text box values and Text Field Values
$ (": Input"). Each (function (){
If ($ (this). ATTR ("type") = "text" | $ (this). ATTR ("type") = "textarea "){
$ (This). Val ("");
}
});
VaR user = $ ("# huserid"). Val ();
If (user! = ""){
$ ("# Txtuserid"). Val (User );
}
// $ ("# Txtuserid"). removeattr ("disabled ");
Document. getelementbyid ("hiddenaction"). value = "add ";
Openwin ("Add User order ");
$ ('# W'). Window ("open ");
Getprodsubnamebyid ($ ("# selprodid"). Val (); // obtain the product subclass of the selected product
});
 
 
// Save
$ ("# Btnsubmit"). Click (function (){
VaR method = $ ("# hiddenaction"). Val ();
If (checkform ()){
Save (method );
}
});
 
Function checkform (){
VaR paymoneysoft = $ ("# txtpaymoneysoft"). Val ();
VaR paymoneyservice = $ ("# txtpaymoneyservice"). Val ();
If ($ ("# txtuserid"). Val () = ""){
Alert ("the user ID cannot be blank! ");
Return false;
} Else if ($ ("# txtorderno"). Val () = ""){
Alert ("order number cannot be blank! ");
Return false;
} Else if ($ ("# selprodid"). Val () = "products used "){
Alert ("select a user product! ");
Return false;
} Else if ($ ("# selprodsubid"). Val () = "Product subclass "){
Alert ("Select Product subclass! ");
Return false;
} Else if ($ ("# txtccuserid"). Val () = ""){
Alert ("Call Center ID cannot be blank! ");
Return false;
} Else if (paymoneysoft = "" & paymoneyservice = ""){
Alert ("select at least one of the software fee and service fee! ");
Return false;
} Else if (paymoneysoft = 0 & paymoneysoft = 0 ){
Alert ("select at least one of the software fee and service fee, and do not enter the number 0! ");
Return false;
} Else {
Return true;
}
}
});

Function openwin (title ){
$ ('# W'). Window ({
Title: title,
Width: 700,
Modal: True,
Shadow: True,
Closed: True,
Height: 650,
Resizable: false
});
}

Function closewin (){
$ ("# W"). Window ("close ");
VaR user = $ ("# huserid"). Val ();
If (user! = ""){
Location. href = "infouser_edit.asp? Id = "+ User; // redirect the page when the page is returned. Otherwise, the prompt box cannot be displayed.
}
}

// Obtain data by ID and display it on the page
Function getpayorderinfobyid (orderid ){
If (orderid! = ""){
$. Ajax ({
Type: "Post ",
URL: "ajaxrequest. asp? Method = infopayorder_manager_getpayorderinfo ",
Data: "orderid =" + orderid,
Success: function (MSG ){
Splitvalue (MSG );
},
Error: function (){
Msgbox ("system prompt", "ajax request failed. Please contact the administrator! "," Error ");
}
});
}
}
// Capture
Function splitvalue (strmsg ){
VaR tempvalue = strmsg. Split ("@@");
For (VAR I = 0; I <tempvalue. length; I ++ ){
$ ("# Txtorderno"). Val (tempvalue [1]);
$ ("# Txtordermoney"). Val (tempvalue [2]);
$ ("# Txtordertime"). Val (tempvalue [3]);
$ ("# Txtuserid"). Val (tempvalue [4]);
$ ("# Txtccuserid"). Val (tempvalue [5]);
$ ("# Selprodid"). Val (tempvalue [6]);
$ ("# Selprodsubid"). Val (tempvalue [7]);
$ ("# Selvasid"). Val (tempvalue [8]);
$ ("# Selpaymode"). Val (tempvalue [9]);
$ ("# Selbankaccount"). Val (tempvalue [10]);
$ ("# Txtpaymoneysoft"). Val (tempvalue [11]);
$ ("# Txtpaymoneyservice"). Val (tempvalue [12]);
$ ("# Txtinvoiceno"). Val (tempvalue [13]);
// $ ("# Ispostinvoice"). Val (tempvalue [14]);
Tempvalue [14] = 0? $ ("# Ispostinvoice"). ATTR ("checked", true): $ ("# nopostinvoice"). ATTR ("checked", true );
$ ("# Txtdatepostinvoice"). Val (tempvalue [15]);
$ ("# Txtcontractno"). Val (tempvalue [16]);
// $ ("# Ispostcontract"). Val (tempvalue [17]);
Tempvalue [17] = 0? $ ("# Ispostcontract"). ATTR ("checked", true): $ ("# nopostcontract"). ATTR ("checked", true );
$ ("# Txtdatepostcontract"). Val (tempvalue [18]);
// $ ("# Contractisok"). Val (tempvalue [19]);
Tempvalue [19] = 0? $ ("# Contractisok"). ATTR ("checked", true): $ ("# contractisnotok"). ATTR ("checked", true );
$ ("# Txtcontractdateok"). Val (tempvalue [20]);
$ ("# Txtremark"). Val (tempvalue [21]);
$ ("# Txtsalesman"). Val (tempvalue [22]);
$ ("# Txtsalesgroup"). Val (tempvalue [23]);
$ ("# Txtremarkitem"). Val (tempvalue [24]);
// $ ("# Isverifyecont"). Val (tempvalue [25]);
Tempvalue [25] = 0? $ ("# Isverifyecont"). ATTR ("checked", true): $ ("# noverifyecont"). ATTR ("checked", true );
$ ("# Txtverifyeconttime"). Val (tempvalue [27]);
$ ("# Txtprodstarttime"). Val (tempvalue [28]); // product Start Time
$ ("# Txtprodendtime"). Val (tempvalue [29]); // Product End Time
Tempvalue [30] = 0? $ ("# Rdoorderstatus"). ATTR ("checked", true): $ ("# rdoorderstatusf"). ATTR ("checked", true); // order status
}
}
// Save the data, add and modify a public Method
Function save (method ){
VaR orderno = $ ("# txtorderno"). Val ();
VaR ordermoney = $ ("# txtordermoney"). Val ();
VaR ordertime = $ ("# txtordertime"). Val ();
VaR vasid = $ ("# selvasid"). Val ();
VaR prodid = $ ("# selprodid"). Val ();
VaR prodsubid = $ ("# selprodsubid"). Val ();
VaR paymode = $ ("# selpaymode"). Val ();
VaR bankaccount = $ ("# selbankaccount"). Val ();
VaR paymoneysoft = $ ("# txtpaymoneysoft"). Val ();
VaR paymoneyservice = $ ("# txtpaymoneyservice"). Val ();
VaR invoiceno = $ ("# txtinvoiceno"). Val ();
VaR ispostinvoice = Document. getelementbyid ("ispostinvoice"). Checked = true? 0: 1; // whether to mail the invoice
VaR contractno = $ ("# txtcontractno"). Val ();
VaR ispostcontract = Document. getelementbyid ("ispostcontract"). Checked = true? 0: 1; // whether to mail the contract
VaR datepostinvoice = $ ("# txtdatepostinvoice"). Val ();
VaR datepostcontract = $ ("# txtdatepostcontract"). Val ();
VaR contractisok = Document. getelementbyid ("contractisok"). Checked = true? 0: 1; // whether the contract is established
VaR contractdateok = $ ("# txtcontractdateok"). Val ();
VaR salesman = $ ("# txtsalesman"). Val ();
VaR salesgroup = $ ("# txtsalesgroup"). Val ();
VaR remarkitem = $ ("# txtremarkitem"). Val ();
VaR userid = $ ("# txtuserid"). Val ();
VaR ccuserid = $ ("# txtccuserid"). Val ();
VaR remark = $ ("# txtremark"). Val ();
VaR verifyeconttime = $ ("# txtverifyeconttime"). Val ();
VaR prodstarttime = $ ("# txtprodstarttime"). Val (); // product Start Time
VaR prodendtime = $ ("# txtprodendtime"). Val (); // Product End Time
VaR orderstatus = Document. getelementbyid ("rdoorderstatus"). Checked = true? 0: 1; // order status
VaR isverifyecont = Document. getelementbyid ("isverifyecont"). Checked = true? 0: 1; // confirm the Electronic Contract

 
VaR selecttr = $ ("# hiddenvalue"). Val ();
 
VaR url = "ajaxrequest. asp ";
Switch (method ){
Case "add ":
Url = URL + "? Method = infopayorder_manager_addpayorder ";
Break;
Case "edit ":
Url = URL + "? Method = infopayorder_manager_editpayorder & selecttr = "+ selecttr;
Break;
}
VaR DATA = "orderno =" + escape (orderno) + "& ordermoney =" + escape (ordermoney) + "& ordertime =" + escape (ordertime) + "& userid =" + escape (userid) + "& ccuserid =" + escape (ccuserid) + "& vasid =" + escape (vasid) + "& prodid =" + escape (prodid) + "& prodsubid =" + escape (prodsubid) + "& paymode =" + escape (paymode) + "& bankaccount =" + escape (bankaccount) + "& paymoneysoft =" + escape (paymoneysoft) + "& paymoneyservice =" + escape (paymoneyservice) + "& invoiceno =" + escape (invoiceno) + "& ispostinvoice =" + escape (ispostinvoice) + "& contractno =" + escape (contractno) + "& ispostcontract =" + escape (ispostcontract) + "& datepostinvoice =" + escape (datepostinvoice) + "& datepostcontract =" + escape (datepostcontract) + "& contractisok =" + escape (contractisok) + "& contractdateok =" + escape (contractdateok) + "& remark =" + escape (remark) + "& salesman =" + escape (salesman) + "& salesgroup =" + escape (salesgroup) + "& remarkitem =" + escape (remarkitem) + "& isverifyecont =" + escape (isverifyecont) + "& verifyeconttime =" + escape (verifyeconttime) + "& prodstarttime =" + escape (prodstarttime) + "& prodendtime =" + escape (prodendtime) + "& orderstatus =" + escape (orderstatus) + "";
$. Ajax ({
Type: "Post ",
URL: URL,
Data: data,
Success: function (MSG ){
If (msg. indexof ("yes ")! =-1 ){
// Msgbox ("system prompt", "Operation successful! "," Info ");
// Location. href = "bankacount_manager.asp ";
VaR user = $ ("# huserid"). Val ();
$. Messager. Alert ("system prompt", "Operation successful", "info", function (){
If (user! = ""){
Location. href = "infouser_edit.asp? Id = "+ User; // redirect the page when the page is returned. Otherwise, the prompt box cannot be displayed.
} Else {
Location. href = "infopayorder_manager.asp"; // redirect the page when the page is returned. Otherwise, the prompt box cannot be displayed.
}

});
} Else if (msg. indexof ("isverifyecont ")! =-1 ){
Msgbox ("system prompt", "This product has an unconfirmed electronic order. Please change this order to the confirmed status first, then add the order for this product, or add orders for other products! "," Info ");
} Else
{
Msgbox ("system prompt", "failed to save data. Please try again later! "+ MSG," info ");
}
},
Error: function (){
Msgbox ("system prompt", "failed to save data. Please contact the administrator! "," Error ");
},
Beforesend: function (){
$ ("# Divmessage" 2.16.html ("<font color = 'red'> submitting data. Please wait ...... </Font> ");
$ ("# Btnsubmit"). ATTR ("disabled", true );
},
Complete: function (){
$ ("# Divmessage" pai.html ("");
$ ("# Btnsubmit"). removeattr ("disabled ");
}
});
}
// Delete the order
Function Delete (orderid ){
If (orderid! = ""){
$. Ajax ({
<A href = "" ajaxrequest. asp? Method = infopayorder_manager_delpayorderinfo "> URL:" ajaxrequest. asp? Method = infopayorder_manager_delpayorderinfo ",
Type: "Post ",
Data: "orderid =" + orderid,
Success: function (MSG ){
If (msg. indexof ("yes ")! =-1 ){
// Msgbox ("system prompt", "deleted successfully! "," Info ");
// Location. href = "bankacount_manager.asp ";
$. Messager. Alert ("system prompt", "Operation successful", "info", function (){
Location. href = "infopayorder_manager.asp ";
});
} Else {
Msgbox ("system prompt", "deletion failed. Please try again later! "+ MSG," info ");
}
},
Error: function (){
Msgbox ("system prompt", "ajax request failed. Please contact the administrator! "," Error ");
}
});
}
}

// Pop-up information window title: Title msgstring: Message msgtype: Information type [error, info, question, warning]
Function msgbox (title, MSG, type ){
$. Messager. Alert (title, MSG, type );
}
 
Function getprodsubnamebyid (prodid ){
If (prodid! = "" & Prodid! = "Products used "){
$. Ajax ({
Type: "Post ",
URL: "ajaxrequest. asp? Method = getprodsubnamebyprodid ",
Data: "prodid =" + prodid,
Success: function (MSG ){
Splitprodsubvalue (MSG );
},
Error: function (){
Msgbox ("system prompt", "ajax failed to load remote data. Please contact the administrator! "," Error ");
}
});
}
}

 
 
Function splitprodsubvalue (strvalue ){
Strvalue = strvalue. substring (0, strvalue. Length-1 );
VaR temparr = strvalue. Split (",");
Document. getelementbyid ("selprodsubid"). Options. Length = 0;
For (VAR I = 0; I <temparr. length; I ++ ){
Document. getelementbyid ("selprodsubid "). options [document. getelementbyid ("selprodsubid "). length] = New Option (temparr [I]. split ("@") [1], temparr [I]. split ("@") [0]);
}
}

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.