您目前尚未登陆,请选择【登陆】或【注册
首页->其他源码->商务维基网源码>>SysConfigure.aspx.cs>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:商务维基网源码
当前文件:文件类型 MerchantViki/SysConfigure.aspx.cs打开代码结构图
普通视图
		            
1using System; 2using System.Data; 3using System.Data.SqlClient; 4using System.Configuration; 5using System.Collections; 6using System.Web; 7using System.Web.Security; 8using System.Web.UI; 9using System.Web.UI.WebControls; 10using System.Web.UI.WebControls.WebParts; 11using System.Web.UI.HtmlControls; 12 13public partial class SysConfigure : System.Web.UI.Page 14{ 15 protected void Page_Load(object sender, EventArgs e) 16 { 17 this.Header.Title = Application.Get("siteName") + "---" + this.Header.Title; 18 19 if (Session["admin"] != null) 20 { 21 if (Session["admin"].ToString().CompareTo("true") == 0) 22 { 23 if (Session["infoTxt"] != null) 24 { 25 info.Text = Session["infoTxt"].ToString(); 26 Session.Remove("infoTxt"); 27 } 28 } 29 } 30 else 31 Response.Redirect("adminLogin.aspx"); 32 } 33 34 private string StringFilter(string inStr) 35 { 36 string outStr; 37 outStr = inStr.Trim().Replace("\'", ""); 38 return outStr; 39 } 40 41 protected void SetSiteNameBtn_Click(object sender, EventArgs e) 42 { 43 string siteNameStr = StringFilter(SiteName.Text); 44 if (siteNameStr.CompareTo("") != 0) 45 { 46 try 47 { 48 string conStr = Application.Get("conStr").ToString(); 49 SqlConnection sqlCon = new SqlConnection(conStr); 50 sqlCon.Open(); 51 52 string cmdStr = "select value from dbo.conf where type='sitename'"; 53 SqlCommand sqlCmd = new SqlCommand(cmdStr, sqlCon); 54 SqlDataReader sqlDR = sqlCmd.ExecuteReader(); 55 if (sqlDR.Read()) 56 { 57 string snStr = sqlDR.GetValue(0).ToString().Trim(); 58 if (snStr.CompareTo(siteNameStr) == 0) //输入的名称与现有名称相同 59 { 60 info.Text = "输入的名称与现有名称相同。"; 61 sqlDR.Close(); 62 } 63 else 64 { 65 sqlDR.Close(); 66 cmdStr = "update dbo.conf set value = '" + siteNameStr + "' where type='sitename'"; 67 sqlCmd.CommandText = cmdStr; 68 sqlCmd.Connection = sqlCon; 69 70 sqlCmd.ExecuteNonQuery(); 71 ChangeSiteName(siteNameStr); 72 } 73 } 74 else 75 { 76 info.Text = "数据库中没有关于网站名称的信息。"; 77 sqlDR.Close(); 78 } 79 80 sqlCon.Close(); 81 } 82 catch (Exception ex) 83 { 84 info.Text = "系统操纵错误:" + ex.Message; 85 } 86 } 87 else 88 info.Text = "网站名称不能为空!"; 89 } 90 91 protected void ChangeSiteName(string snStr) 92 { 93 string infoStr = "网站名称修改为:" + snStr; 94 Session.Add("infoTxt", infoStr); 95 Application.Lock(); 96 Application.Set("siteName", snStr); 97 Application.UnLock(); 98 Response.Redirect("sysConfigure.aspx"); 99 } 100 101 protected void SetAdminPwdBtn_Click(object sender, EventArgs e) 102 { 103 string adminPwdStr = StringFilter(AdminPwd.Text); 104 105 if (adminPwdStr.CompareTo("") != 0) 106 { 107 try 108 { 109 string conStr = Application.Get("conStr").ToString(); 110 SqlConnection sqlCon = new SqlConnection(conStr); 111 sqlCon.Open(); 112 113 string pwdMD5 = FormsAuthentication.HashPasswordForStoringInConfigFile(adminPwdStr, "MD5").ToString(); 114 string cmdStr = "select value from dbo.conf where type='adminPwd'"; 115 SqlCommand sqlCmd = new SqlCommand(cmdStr, sqlCon); 116 SqlDataReader sqlDR = sqlCmd.ExecuteReader(); 117 118 if (sqlDR.Read()) 119 { 120 sqlDR.Close(); 121 ChangeAdminPwd(adminPwdStr,sqlCon); 122 } 123 else 124 { 125 info.Text = "数据库中没有关于管理员密码的信息。"; 126 sqlDR.Close(); 127 } 128 129 sqlCon.Close(); 130 } 131 catch (Exception ex) 132 { 133 info.Text = "系统操纵错误:" + ex.Message; 134 } 135 } 136 else 137 info.Text = "密码不能为空!"; 138 } 139 140 protected void ChangeAdminPwd(string pwd,SqlConnection con) 141 { 142 string cmdStr = "update dbo.conf set value = '" + FormsAuthentication.HashPasswordForStoringInConfigFile(pwd,"MD5").ToString() + "' where type='adminPwd'"; 143 SqlCommand sqlCmd = new SqlCommand(cmdStr,con); 144 145 sqlCmd.ExecuteNonQuery(); 146 info.Text = "修改后的管理员密码为:" + pwd; 147 } 148 149 protected void LoginOutBtn_Click(object sender, EventArgs e) 150 { 151 Session.Remove("admin"); 152 Response.Redirect("default.aspx"); 153 } 154} 155
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:商务维基网源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号