involves changing passwords, submitting request actions, and modifying database content
1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingsystem.web;5 usingSystem.Web.UI;6 usingSystem.Web.UI.WebControls;7 usingSystem.Data.SqlClient;8 usingSystem.Data.Sql;9 usingSystem.Data;Ten One Public Partial classModifyInfo:System.Web.UI.Page A { - protected voidPage_Load (Objectsender, EventArgs e) - { the - } - //Modify the interface, modify the change request - protected voidFormview1_itemupdating (Objectsender, Formviewupdateeventargs e) + { -E.cancel =true;//canceling a modification event to a system framework + //get input information and compose SQL statements A stringBGQQ = ((TextBox) Formview1.findcontrol ("Stdbgqqtextbox")). Text; at stringStdxh = session["Stdxh"]. ToString (); - stringsql ="update stdinfo Set [email protected] where [email protected]"; -sqlparameter[] param ={ - NewSqlParameter ("@bgqq", Sqldbtype.text), - NewSqlParameter ("@stdXh", SqlDbType.Char) - }; inparam[0]. Value =bgqq; -param[1]. Value =Stdxh; to //Execute SQL statement, modify database + sqlhelp.executenonequery (sqlhelp.connectionstringlcaltransaction, CommandType.Text, SQL, param); - //Reload This page to refresh the data theResponse.Redirect ("modifyinfo.aspx?stdxh="+stdxh); * } $ //Modify Password button handle eventPanax Notoginseng protected voidLinkButton1_Click (Objectsender, EventArgs e) - { the //get the new and old password entered and the user name saved at login + stringOldPassword = TxtOldPassword.Text.Replace ("'",""); A stringNewPassword = TxtNewPassword.Text.Replace ("'",""); the stringStdxh = session["Stdxh"]. ToString (); + //querying the database to verify that the old password is correct - stringsql = $ "Select COUNT (*) from stdinfo where [email protected] and [email protected]"; $SqlParameter []param={ - NewSqlParameter ("@stdXh", Sqldbtype.text), - NewSqlParameter ("@stdMm", Sqldbtype.text) the }; -param[0]. Value=Stdxh;Wuyiparam[1]. Value=OldPassword; the intUsercount= ((int) (Sqlhelp.executescalar (Sqlhelp.connectionstringlcaltransaction,commandtype.text,sql,param) )); - if(usercount<=0)//if the query is not logged, it indicates an old password error Wu { -Labmsg.text ="Old password Error"; About } $ Else{ - //perform a database operation to modify a password - stringUpdatesql= - "update stdinfo Set [email protected] where [email protected]"; ASqlParameter []updateparam={ + NewSqlParameter ("@stdXh", Sqldbtype.text), the NewSqlParameter ("@stdMm", Sqldbtype.text) - }; $param[0]. Value=Stdxh; theparam[1]. Value=NewPassword; the if(Sqlhelp.executenonequery (Sqlhelp.connectionstringlcaltransaction,commandtype.text,updatesql,updateparam) >0) the { thelabmsg.text="Modification succeeded"; - } in Else the { thelabmsg.text="Modification Failed"; About } the } the } the}
ModifyInfo.aspx.cs Code