ÄúĿǰÉÐδµÇ½£¬ÇëÑ¡Ôñ¡¾µÇ½¡¿»ò¡¾×¢²á¡¿
Ê×Ò³->ȫվ´úÂë->XMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©>>index.aspx.cs>>´úÂëÔÚÏ߲鿴
ÎÂܰÌáʾ£º´úÂëÔÚÏßä¯ÀÀ¹¦ÄÜÖ»ÄÜ×öΪԴÂëä¯ÀÀ²Î¿¼£¬²»ÄÜչʾÏîÄ¿µÄÈ«²¿£¬Èç¹ûÏë¸ü½øÒ»²½Á˽â¸Ã´úÂëÇëÏÂÔØ£ºXMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©


µ±Ç°Îļþ·¾¶£ºXMLClassBooks/index.aspx.cs ÎļþÀàÐÍ
ÆÕͨÊÓͼ
		            
1using System; 2using System.Data; 3using System.Configuration; 4using System.Collections; 5using System.Web; 6using System.Web.Security; 7using System.Web.UI; 8using System.Web.UI.WebControls; 9using System.Web.UI.WebControls.WebParts; 10using System.Web.UI.HtmlControls; 11 12using System.IO; 13using xmlOp; //ÒýÈëXmlOpÃüÃû¿Õ¼ä 14 15public partial class index : System.Web.UI.Page 16{ 17 18 string _xmlFile = ConfigurationManager.AppSettings["xmlFile"]; 19 string _userName = ""; //¼Ç¼Óû§Ãû±äÁ¿ 20 string _userPwd = ""; //¼Ç¼Óû§ÃÜÂë±äÁ¿ 21 22 Logic lg = new Logic(); //ÉùÃ÷Ò»¸öLogicÀà¶ÔÏó 23 DataSet ds = new DataSet(); //´´½¨Ò»¸ö¿ÕDataSe¶ÔÏó 24 25 protected void Page_Load(object sender, EventArgs e) 26 { 27 28 //¶ÁÈ¡CookieÀïµÄÕʺźÍÃÜÂë²¢¸³Öµ¸ø±äÁ¿ 29 HttpCookie cookie = Request.Cookies["userInfo"]; 30 if (cookie != null) 31 { 32 _userName = cookie.Values["userName"].ToString(); 33 _userPwd = cookie.Values["userPwd"].ToString(); 34 } 35 //Ò³ÃæµÚÒ»´Î¼ÓÔØ 36 if (!IsPostBack) 37 { 38 if (_userName == null || _userName=="") //·Ç·¨·ÃÎÊʱ 39 { 40 Response.Write("ÄãûÓеǼ£¬<a href='default.aspx'>ÇëµÇ¼</a> !"); 41 Response.End(); 42 } 43 BindToDataGrid(); //µ÷ÓÃÊý¾Ý°ó¶¨º¯Êý 44 } 45 } 46 47 48 //Êý¾Ý°ó¶¨µ½DataGrid£¬ÏÔʾ°à¼¶ËùÓгÉÔ± 49 private void BindToDataGrid() 50 { 51 try 52 { 53 XmlOp op = new XmlOp(_xmlFile); //ÉùÃ÷XmlOpÀà¶ÔÏó 54 ds = op.GetDs("//Root"); 55 this.DataGrid1.DataKeyField = "Name"; //Êý¾Ý±í¹Ø¼ü×ֶμ¯ºÏ 56 this.DataGrid1.DataSource = ds; 57 this.DataGrid1.DataBind(); 58 Session["thisDS"] = ds; //°ÑÊý¾Ý¼¯±£´æµ½Session±äÁ¿ÖÐ 59 BindToRepeater(this.Repeater1,1); //°ó¶¨Repeater1 60 } 61 catch 62 { 63 Response.Write("³öÏÖ²»Ã÷´íÎó !"); 64 Response.End(); 65 } 66 } 67 68 69 //Êý¾Ý°ó¶¨µ½Repeater 70 private void BindToRepeater(Repeater rp,int p) 71 { 72 XmlOp op = new XmlOp(_xmlFile); 73 ds = op.GetDs("//Root/Student[Name='" + _userName + "']"); 74 P1_P2(p); 75 rp.DataSource = ds.Tables[0].DefaultView; 76 rp.DataBind(); 77 } 78 //Á½¸öÄ£°åÖ»ÏÔʾһ¸ö 79 private void P1_P2(int i) 80 { 81 if (i == 1) //ÏÔʾRepeater1 82 { 83 this.Repeater2.Visible = false; 84 this.Repeater1.Visible = true; 85 } 86 if (i == 2) //ÏÔʾRepeater2 87 { 88 this.Repeater2.Visible = true; 89 this.Repeater1.Visible = false; 90 } 91 } 92 93 //ÐÞ¸ÄÐÅÏ¢°´Å¥ 94 protected void btnShowP2_Click(object sender, EventArgs e) 95 { 96 BindToRepeater(this.Repeater2, 2); //°ó¶¨Repeater2 97 } 98 99 100 //ÐÞ¸ÄÎÒµÄÐÅÏ¢ 101 protected void btnUpdate_Click(object sender, EventArgs e) 102 { 103 if (IsValid) //ͨ¹ýÑéÖ¤ 104 { 105 string _nickName = ((TextBox)this.Repeater2.Items[0].FindControl("txtNickName")).Text.Trim(); 106 string _pwd = ((TextBox)this.Repeater2.Items[0].FindControl("txtPwd")).Text.Trim(); 107 string _birthday = ((TextBox)this.Repeater2.Items[0].FindControl("txtBirthday")).Text.Trim(); 108 string _qq = ((TextBox)this.Repeater2.Items[0].FindControl("txtQQ")).Text.Trim(); 109 string _msn = ((TextBox)this.Repeater2.Items[0].FindControl("txtMsn")).Text.Trim(); 110 string _Tel = ((TextBox)this.Repeater2.Items[0].FindControl("txtTel")).Text.Trim(); 111 string _Email = ((TextBox)this.Repeater2.Items[0].FindControl("txtEmail")).Text.Trim(); 112 string _address = ((TextBox)this.Repeater2.Items[0].FindControl("txtAddress")).Text.Trim(); 113 string _work = ((TextBox)this.Repeater2.Items[0].FindControl("txtWork")).Text.Trim(); 114 string _homepage = ((TextBox)this.Repeater2.Items[0].FindControl("txtHomepage")).Text.Trim(); 115 string _photo = ((FileUpload)this.Repeater2.Items[0].FindControl("FileUploadImage")).FileName; 116 string _photoType = ((FileUpload)this.Repeater2.Items[0].FindControl("FileUploadImage")).PostedFile.ContentType; 117 string _time = DateTime.Now.ToString(); 118 try 119 { 120 XmlOp op = new XmlOp(_xmlFile); 121 string _type = _photoType; 122 string _file = _photo.ToLower(); 123 if (_photo != "") //Èç¹ûûÓÐÑ¡ÔñͼƬʱ£¬¾Í²»ÐèÐ޸ļǼÖеÄPhotoÊôÐÔ 124 { 125 if (_photoType.Substring(0, 5) == "image") 126 { 127 //ÉÏ´«Í¼Æ¬ 128 _photo = "images/" + _userName + _file.Substring(_file.LastIndexOf(".")); 129 ((FileUpload)this.Repeater2.Items[0].FindControl("FileUploadImage")).SaveAs(Server.MapPath(_photo)); 130 } 131 else 132 { 133 lg.Msg("ͼƬ¸ñʽ²»¶Ô!"); 134 return; 135 } 136 string _xmlParentNode = "//Root/Student[Name='" + _userName + "']"; 137 string[] _xmlNode ={ "NickName", "Pwd", "Birthday", "QQ", "Msn", "Tel", "Email", "Address", "Work", "Homepage", "Photo", "Time", }; 138 string[] _xmlNodeTxt ={ _nickName, _pwd, _birthday, _qq, _msn, _Tel, _Email, _address, _work, _homepage, _photo, _time }; 139 op.UpdateNode(_xmlParentNode, _xmlNode, _xmlNodeTxt); 140 } 141 else //Ñ¡ÔñÁËͼƬ£¬ÐèÒªÐ޸ļǼÖеÄPhotoÊôÐÔ 142 { 143 string _xmlParentNode = "//Root/Student[Name='" + _userName + "']"; 144 string[] _xmlNode ={ "NickName", "Pwd", "Birthday", "QQ", "Msn", "Tel", "Email", "Address", "Work", "Homepage", "Time", }; 145 string[] _xmlNodeTxt ={ _nickName, _pwd, _birthday, _qq, _msn, _Tel, _Email, _address, _work, _homepage,_time }; 146 op.UpdateNode(_xmlParentNode, _xmlNode, _xmlNodeTxt); 147 } 148 op.Save(_xmlFile); //±£´æÐµÄÐÅÏ¢ 149 BindToRepeater(this.Repeater1,1); //ÖØÐ°ó¶¨Repeater1¿Ø¼þ 150 lg.Msg("ÄãµÄµÇ¼ÃÜÂëÒÑÐÞ¸ÄΪ '" + _pwd + "'"); 151 } 152 catch 153 { 154 lg.Msg("ÐÞ¸Äʧ°Ü!"); 155 } 156 } 157 } 158 159 //È¡ÏûÐÞ¸Ä 160 protected void btnCancer_Click(object sender, EventArgs e) 161 { 162 P1_P2(1); //ÏÔʾRepeater1£¬Òþ²ØRepeater2 163 } 164 165 //°ó¶¨µ½Ç°Ì¨ÕÕÆ¬ÕÕÆ¬ÏÔʾµÄº¯Êý 166 public string Img(string img, string sex) 167 { 168 if (img == "") //ûÓÐͼƬʱ 169 { 170 if (sex == "ÄÐÉú") 171 return "img/boy.gif"; //ÏÔʾĬÈϵÄÄÐÉúͼƬ 172 else 173 return "img/girl.gif"; //ÏÔʾĬÈϵÄÅ®ÉúͼƬ 174 } 175 else //ÓÐͼƬʱ 176 return img; 177 } 178 179 //°ó¶¨µ½Ç°Ì¨µ±Ç°µÇ½Óû§Éí·ÝµÄº¯Êý 180 public string Admin(string admin) 181 { 182 if (admin == "yes") //ÊÇÒ»°ã¹ÜÀíÔ± 183 { 184 Session["NormalAdmin"] = "yes"; //½«Éí·ÝÐÅϢдÈëSessionÖÐ 185 return "<a href='admin.aspx' target='_blank'>¹ÜÀí°à¼¶</a>"; 186 } 187 else //²»ÊÇÒ»°ã¹ÜÀíÔ± 188 return "·Ç¹ÜÀíÔ±"; 189 } 190 191 //²éÕÒͬѧ 192 protected void btnFind_Click(object sender, EventArgs e) 193 { 194 DataTable newDt = new DataTable(); //´´½¨Ò»¸öеĿձí 195 DataTable dt = ((DataSet)Session["thisDS"]).Tables[0]; //¶ÁÈ¡SessionÖеıí 196 newDt = dt.Clone(); //¿Ë¡±í 197 DataRow[] dr = dt.Select("Name like '%" + this.txtStuName.Text + "%'"); //²éÕÒͬѧ²¢·ÅÈëÊý¾ÝÐÐÊý×é 198 for (int i = 0; i < dr.Length; i++) 199 { 200 newDt.ImportRow((DataRow)dr[i]); //ÖØ×éеÄÊý¾Ý±í 201 } 202 this.DataGrid1.DataSource = newDt.DefaultView; //DataGrid1ÖØÐÂ°ó¶¨ 203 this.DataGrid1.DataBind(); 204 } 205 206 207} 208
»¹Ã»ÓÐÕÒµ½ÄúÐÄÒǵÄÄÚÈÝ£¿ÇëÓÃ.netÔ´Âë´óËѲ¶
´úÂëÆ¬¶Ï ´ò°üÏÂÔØ¸ÃÏîÄ¿ÍêÕûÔ´Â룺XMLͬѧ¼ϵͳԴÂ루±ÏÒµÉè¼Æ£©

- IFNuke(ÐÞ¸Ä×ÔDNN)ÍøÕ¾Ô´Âë

- ¶àÓû§ÎļþÉÏ´«¹ÜÀí³ÌÐòÔ´Âë

- UrlReWrite(UrlÖØÐ´»òα¾²Ì¬..

- atlasÆ´ÒôÊ××ÖĸÎı¾¿ò×Ô¶¯Íê..

- ¿â´æ¹ÜÀíϵͳV1.0Ô´Âë

- Asp.netµ¯³ö¶Ô»°¿òºº»¯ÐÞÕý°æ..

- С¿××ÓÐÂÎÅϵͳ2.0£¨È«²¿C#Ô´..

- ͨÓÃÉÏ´«Ô´Â루¹¦ÄÜÇ¿´ó£¬½ç..

51Aspx.com °æÈ¨ËùÓÐ CopyRight © 2000-2008. ¾©ICP±¸06046876ºÅ