Written by the leader, DAL layer Update
1 //Edit2 Public intUpdate (dictionary<string,Object> par,Longuid)3 {4 if(Par. Count = =0)return 0;5StringBuilder SQL =NewStringBuilder ();6Sql.append ("UPDATE uc_user SET");7Sqlparameter[] Pars =NewSqlparameter[par. Count +1];8 string[] fields =New string[par. Count];9 intindex =0;Ten foreach(stringNameinchpar. Keys) One { ASql.appendformat ("["+ name +"] [email protected]_{0},", index); -Pars[index] =NewSqlParameter ("@p_"+index. ToString (), Par[name]); -index++; the } -Sql.remove (Sql.length-1,1); -Sql.append ("WHERE"); -Sql.append ("[UID] = @p_"+index. ToString ()); +Pars[index] =NewSqlParameter ("@p_"+index. ToString (), UID); -index++; + returnsqlhelper.executenonquery (ConnectionString, CommandType.Text, sql.tostring (), pars); A}
Modify user name, the BLL layer only need to pass in the corresponding password
1 Public Static intUpdate (dictionary<string,Object> par,LongAUID)2 {3 returndal. Update (par, AUID);4 }5 6 Public Static intEditpwd (stringPwdLongAuid)7 {8dictionary<string,Object> dic =Newdictionary<string,Object>();9Dic. ADD ("UserPassword", Utils.md5 (PWD));Ten returnUpdate (DIC, Auid); One}
Then the web layer is called on the line
1 BLL. UC.USERB2B.EDITPWD (Newpwd, Currentuser.uid);
Because it is a dictionary loop call, the fixed incoming modification of what column, on what column to modify, the condition of their own definition, very flexible
The DAL layer modifies the SQL table data