In the after-sales management system in the pate, one of the nodes is fault analysis, that is, to send back the whole machine for fault analysis, the traditional method is to input the fault information of each machine into an Excel table, table Excel style:
Here is the ability to convert Excel into a template page and then replace the tags in the template as needed to fully demonstrate the functionality, as described in this feature in the project implementation steps:
1. Convert Excel to a Web page
Open the Excel document, click File in the menu bar, and find Save As. In the Save As window, find "Single File page" in the "Saving type" drop-down menu. Name from which I remembered.
2. Modify the template page
Let's take a look at the static template page (HTM page) that generates the template headers and tails in Excel, and the page # number shows the tags that need to be replaced:
Take a look at this part of the code implementation, these are simple HTML code, the page code converted by Excel slightly modified the following:
<body style= "width:95%; margin:0 Auto; padding:20px; " > <form name= "form" method= "POST" action= "#" > [#ChaiFenID #] <table border= "1px" style= "border-collaps E:collapse; " > <tr style= "text-align:center;" > <td colspan= "class=" Style1 "> Starter Failure Analysis Table (Class A) </td> </TR&G T <tr> <td colspan= "2" class= "Style2" > Factory two-dimensional </td> <td C olspan= "5" class= "Style3" > [#CCEWM #] </td> <td colspan= "3" class= "Style2" > aftermarket QR code </td> <TD colspan= "5" class= "Style3" > [#SHEWM #] </td> </tr> <tr> <td rowspan= "2" class= "Style5" > Info </td> <td class= "Style6" > Feedback units </td> &L T;TD colspan= "3" Class= "Style7" > [#FKDW #] </td> <td class= "Style6" > Feedback Date </td> <td colspan= "2" class= "Style7" > [#FKRQ #] </td> <TD class= "Style5" > Models </td> <td colspan= "2" class= "Style7" ; [#XH #] </td> <td class= "Style5" > Serial number </td> &L T;TD colspan= "3" class= "Style7" > [#XLH #] </td> </tr> <tr> <TD class= "Style6" > Three charters </td> <td class= "Style5" > [#SBJ #] </td> <td class= "Style6" > 0 km </td> <TD class= "Style6" > Appearance photos </td> <td colspan= "5" class= "Style8" ; </td> <td colspan= "3" class= "Style5" > Performance is normal </td> <TD colspan= "2" class= "Style10" > <input id= "Radio1" type= "Radio" name= "yes" value= "yes"/> Yes <input id= "Radio2" type= "Radio" valule= "no"/> No </td> </tr> <tr> <TD class= "Style5" > Fault <br/> Parts </td> < TD class= "Style6" > Symptom </td> <td class= "style5" > Fault &L t;br/> Phenomenon </td> <td class= "Style6" > Fault phenomena &L t;/td> <td class= "style5" > Fault <br/> Phenomenon </td> <TD class= "Style6" > Symptoms </td> <td class= "Style5" > Fault <br/> Phenomenon </td> <td class= "Style6" > Symptom </td> <TD class= "Style5" > Fault <br/> phenomenon </td> <TD class= "Style6" > Symptom </td> <td class= "style5" > Fault <br /> Phenomena </td> <td class= "Style6" > Fault phenomena </t d> <td class= "style5" > Fault <br/> Phenomenon </td> <TD class= "Style6" > Symptoms </td> <td class= "Style5" > Fault <br/> Phenomenon </td> </tr> [#Body #] <tr> <TD rowspan= "2" class= "Style5" > Other <br/> J </td> < TD class= "Style4" > 1 user disintegration </td> <td class= "Style5" > </td> <td C Olspan= "2" class= "Style4" > Missing pieces to note </td> <td class= "Style4" > 2 into foreign bodies </td> <TD class= "Style5" > </td> <td colspan= "2" class= "Style4" > What foreign body to note </td> <td class= "Style4" > 3 dust </td> <td class= "Style5" > </td> <td class= "Style4" > 4 Inlet </td> <td class= "Style5" > </td> <td clas s= "Style4" > 5 oil </td> <td class= "Style5" > </td> </tr> <tr> <td class= "Style4" > 6 wrong-fit </td> <TD class= "Style5"; </td> <td colspan= "2" class= "Style5" > </td> <td class= "Style4" > 7 piercing </td> <td class= "Style5" > </td> <TD CL ass= "Style4" > 8 Whole machine rust </td> <td class= "Style5" > </td> <TD class= "Style4" > </td> <td class= "Style5" > </td> <TD class= "Style4" > </td> <td class= "Style5" > </td> <TD class= "Style5" > </td> <td class= "Style5" > </td> </tr> <tr> <td class= "Style5" > Remarks <br/> K </td> <td class= "Style4" > 1 </td> <td class= "style 5 "> </td> <td class= "Style4" > 2 </td> <td class= "s Tyle5 "> </td> <td class=" Style4 "> 3 </td> <TD class= "Style5" > </td> <td class= "Style4" > 4 </td& Gt <TD class= "Style5" > </td> <td class= "Style4" > 5 </td& Gt <TD class= "Style5" > </td> <td class= "Style4" > 6 </td& Gt <TD class= "Style5" > </td> <td class= "Style4" > 7 </td& Gt <TD class= "Style5" > </td> </tr> <tr> <td colspan= "" "Class = "Style11" > Note: Please use circle to display the number of the preceding digit in the space "√" after the corresponding fault phenomenon and the phenomenon of part failure.</td> </tr> <tr> <td class= "Style5" > </td> &L T;TD colspan= "2" class= "Style12" > Analyst: </td> <td colspan= "4" class= "style "> </td> <td class=" Style12 "> </td> <td colspan=" 3 " class= "Style12" > Analysis Date: </td> <td colspan= "3" class= "Style12" > </td> <td class= "Style12" > </td> </tr> </table> <in Put type= "button" name= "Query" onclick= "return Dosubmit ()" language= "JavaScript" value= "commit"/> </form> </body>
3.ASP. NET Read Template page
ASP. NET reads the template page as follows, and the effect of accessing this page is the same as the generated template page:
String mbpath = Server.MapPath ("faultmangaetemplate.htm"); Template page Encoding code = encoding.getencoding ("gb2312"); Character encoding StreamReader sr = null; string str = NULL; Read try {sr = new StreamReader (Mbpath, code); str = Sr. ReadToEnd (); Str= Str. Replace ("[#Body #]", tablebody); Replace method that replaces the label in the template that needs to be replaced by str = str. Replace ("[#FKDW #]", enwxjd.dlsname); str = str. Replace ("[#FKRQ #]", enwxjd.dddate); str = str. Replace ("[#XH #]", LJXH); str = str. Replace ("[#ChaiFenID #]", "<input id=\" hidchaifenid\ "type=\" hidden\ "value=\" "+ Chaifenid +" \ "/>"); str = str. Replace ("[#SBJ #]", "yes"); } catch (Exception ex) {throw ex; } finally {Sr. Close (); } response.clear (); Response.Write (str); Response.End ();
There are some tags on the template part generated above, look at the HTML code for the label replacement of the body part of the page:
<summary>//////To generate HTML//</summary> private String Bindgzjbjxx () {string) in conjunction with faulty parts and components failure information Strhtml= ""; DataTable DTGZBJ = new Bt_ljgz_gzmanage (). Queryallgzbjbygzzl ("starter"); for (int i = 0; i < DtGZBJ.Rows.Count; i++) {if (i = = 0) {strhtml = "< tr> <td class=\ "style5\" "; } else {strhtml + = "<tr> <td class=\" style5\ ""; } strhtml + = "rowspan=\" "; DataTable dtgzxx = new Bt_ljgz_gzmanage (). QUERYALLGZXXBYGZBJ (Convert.ToInt32 (dtgzbj.rows[i]["ID"])); Double rowspan = math.ceiling (double) DtGZXX.Rows.Count/(double) 7); Each row shows 7 fault messages strhtml + = convert.tostring (rowspan); strHTML + = "\" > "; strHTML + = convert.tostring (dtgzbj.rows[i]["GZBJ"]); strHTML + = "</td>"; for (int j = 0; j < DtGZXX.Rows.Count; j=j+7) { if (j% 7 = = 0) {if (J! = 0) {strhtml + = "<tr>"; } for (int z = j; z < j + 7; z++) {if (Z < DtGZXX.Rows.Count) {strhtml + = "<td class=\" style4\ ">"; strHTML + = convert.tostring (dtgzxx.rows[z]["GZMC"]); strHTML + = "</td>"; strHTML + = "<td class=\" style5\ ">"; strHTML + = "<input value=\" + dtgzxx.rows[z]["ID"]. ToString () + "\" "; strHTML + = "name=\" input\ "type=\" checkbox\ "/>"; strHTML + = "</td>"; } else {strhtml + = "<td class=\" style4\ ">"; strHTML + = "</td>"; strHTML + = "<td class=\" style5\ ">"; strHTML + = "</td>"; }} strhtml + = "</tr>"; }}} return strhtml; }
Here's a look at the feature implementation page:
This function is simply introduced here, the reason will write this blog, is because the design and implementation of this feature is the first time to do, just start to realize this function when you do not know where to start, the completion of the discovery actually it is quite simple, all the experience from experience, experience more, experience will be more!
A small collection of project experience (6) ___asp. NET Template page Reads