diff --git "a/15\345\220\264\346\230\216\346\235\260/22-05-16-\350\256\241\347\256\227\345\231\250.md" "b/15\345\220\264\346\230\216\346\235\260/22-05-16-\350\256\241\347\256\227\345\231\250.md" deleted file mode 100644 index 6a6315d83d72423524c838613ad2eeb16e830ded..0000000000000000000000000000000000000000 --- "a/15\345\220\264\346\230\216\346\235\260/22-05-16-\350\256\241\347\256\227\345\231\250.md" +++ /dev/null @@ -1,52 +0,0 @@ -```html -
-
- -
- -
- - - - -
- - -
-
-``` - -```c# - public partial class WebForm2 : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - - } - - protected void jia_Click(object sender, EventArgs e) - { - int a = Convert.ToInt32(text1.Text) + Convert.ToInt32(text2.Text); - text3.Text = a.ToString(); - } - - protected void jian_Click(object sender, EventArgs e) - { - int a = Convert.ToInt32(text1.Text) - Convert.ToInt32(text2.Text); - text3.Text = a.ToString(); - } - - protected void chen_Click(object sender, EventArgs e) - { - int a = Convert.ToInt32(text1.Text) * Convert.ToInt32(text2.Text); - text3.Text = a.ToString(); - } - - protected void chu_Click(object sender, EventArgs e) - { - int a = Convert.ToInt32(text1.Text) / Convert.ToInt32(text2.Text); - text3.Text = a.ToString(); - } - } -``` - diff --git "a/38\345\274\240\351\235\231/.keep" "b/38\345\274\240\351\235\231/.keep" deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git "a/38\345\274\240\351\235\231/WebApplication1.sln" "b/38\345\274\240\351\235\231/WebApplication1.sln" deleted file mode 100644 index 2914581e1dfcbb988b7ca6fd6af39d3882a705ed..0000000000000000000000000000000000000000 --- "a/38\345\274\240\351\235\231/WebApplication1.sln" +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30320.27 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "WebApplication1\WebApplication1.csproj", "{03FF2EEE-7086-4C6F-8312-C3ADB715C26E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {03FF2EEE-7086-4C6F-8312-C3ADB715C26E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {03FF2EEE-7086-4C6F-8312-C3ADB715C26E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {03FF2EEE-7086-4C6F-8312-C3ADB715C26E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {03FF2EEE-7086-4C6F-8312-C3ADB715C26E}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E38F2122-7A82-4F51-A14C-42DDEA94B4F7} - EndGlobalSection -EndGlobal diff --git "a/\347\224\260\351\221\253\345\274\272/ASP.NET\344\275\234\344\270\232.md" "b/\347\224\260\351\221\253\345\274\272/ASP.NET\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..9e7740017d832f964477f9d6f2e1f08fa229feb3 --- /dev/null +++ "b/\347\224\260\351\221\253\345\274\272/ASP.NET\344\275\234\344\270\232.md" @@ -0,0 +1,369 @@ +# 登录界面 + +## 登录 + +### WebForm1.aspx + +```asp +
+ 用户名: + +
+ 密码: + +
+ + + + +
+ 用户人数为: + +
+``` + +### 后端 + + + +```c# + public partial class WebForm1 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; + } + + protected void Button1_Click(object sender, EventArgs e) + { + //1.获取数据 + string account = TextBox1.Text.Trim(); + string pwd = TextBox2.Text.Trim(); + string sql = $"select * from MyUser where UserAccount='{account}' and UserPwd = '{pwd}'"; + + //2.创建新的数据验证类 + DataTable dataTable = SQL.DBhelper.Query(sql); + //3.验证账号密码是否正确 + if (dataTable.Rows.Count>0) + { + Session["UserLoginId"] = TextBox1.Text;//将用户ID保存到session + string loginId = Session["UserLoginId"].ToString();//读取session的值 + Response.Write(loginId);//输出session的值 + } + else + { + Response.Write(""); + } + + } + + protected void Button2_Click(object sender, EventArgs e) + { + Response.Redirect("WebForm2.aspx"); + } + + protected void Button3_Click(object sender, EventArgs e) + { + //1.获取数据 + string account = TextBox1.Text.Trim(); + string pwd = TextBox2.Text.Trim(); + string sql = $"select * from MyUser where UserAccount='{account}' and UserPwd = '{pwd}'"; + + //2.创建新的数据验证类 + DataTable dataTable = SQL.DBhelper.Query(sql); + + if (dataTable.Rows.Count > 0) + { + Response.Redirect("WebForm3.aspx"); + } + else + { + Response.Write(""); + } + + } + + protected void Button4_Click(object sender, EventArgs e) + { + //1.获取数据 + string account = TextBox1.Text.Trim(); + string pwd = TextBox2.Text.Trim(); + string sql = $"select * from MyUser where UserAccount='{account}' and UserPwd = '{pwd}'"; + + //2.创建新的数据验证类 + DataTable dataTable = SQL.DBhelper.Query(sql); + //3.验证账号密码是否正确 + if (dataTable.Rows.Count > 0) + { + Response.Redirect("WebForm4.aspx"); + } + else + { + Response.Write("alert('用户名或密码错误')"); + } + + } + } +``` + +## 注册 + +### WebForm2.aspx + + + +```asp +
+ 用户名: + +
+ 密码: + +
+ 密码确认: + + +
+ 密保问题: + 自定义 + 小学读哪里? + 高中老师是谁 + 妈妈的生日 + +
+ +
+ 密保答案: +
+ 邮箱: + + +
+ 联系电话: + + +
+ 性别: +
+ 专业: + 请选择 + 软件技术 + 人力资源管理 + 电子商务 + 土木工程 + +
+ 自我介绍: +
+ + + + +
+``` + +### 后端 + +```c# +public partial class WebForm2 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; + } + //注册按钮 + protected void Button1_Click(object sender, EventArgs e) + { + string account = TBname.Text.Trim();//账号 + string verify = $"select * from MyUser where UserAccount = '{account}'"; + + DataTable dataTable = SQL.DBhelper.Query(verify); + + if (dataTable.Rows.Count==0) + { + string pwd = TBpwd2.Text.Trim();//密码 + string qestion = TBproblem.Text.Trim();//密保问题 + string answer = TBanswer.Text.Trim();//密保答案 + string email = TBemail.Text.Trim();//邮箱 + string phone = TBnumber.Text.Trim();//手机号码 + string prof = DropDownList2.Text.Trim();//专业 + string self = TBtext.Text.Trim();//自我介绍 + + if (RBgender1.Checked)//性别 + { + string sex = "男"; + string sql = $"insert into MyUser(UserAccount,UserPwd,Question,Answer,UserMail,UserPhone,UserSex,UserProf,UserSelf) values('{account}', '{pwd}','{qestion}','{answer}','{email}','{phone}','{sex}','{prof}','{self}')"; + int result = SQL.DBhelper.NonQuery(sql); + if (result > 0) + { + Literal1.Text = "注册成功"; + } + else + { + Literal1.Text = "注册失败"; + } + + } + else + { + string sex = "女"; + string sql = $"insert into MyUser(UserAccount,UserPwd,Question,Answer,UserMail,UserPhone,UserSex,UserProf) values('{account}', '{pwd}','{qestion}','{answer}','{email}','{phone}','{sex}','{prof}','{self}')"; + int result = SQL.DBhelper.NonQuery(sql); + if (result > 0) + { + Literal1.Text = "注册成功"; + } + else + { + Literal1.Text = "注册失败"; + } + } + } + else + { + Response.Write(""); + } + + + } + + //取消按钮 + protected void Button2_Click(object sender, EventArgs e) + { + Response.Redirect("WebForm1.aspx"); + } + } +``` + +## 修改密码 + +### WebForm3.aspx + +```asp +
+ 用户名: +
+ 旧密码: +
+ 新密码: + +
+ + +
+``` + +### 后端 + +```c# +public partial class WebForm3 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; + } + + protected void Button1_Click(object sender, EventArgs e) + { + string account = TBaccount.Text.Trim(); + string oldPwd = TBOldPwd.Text.Trim(); + string newPwd = TBNewPwd.Text.Trim(); + string sql = $"select * from MyUser where UserAccount='{account}' and UserPwd = '{oldPwd}'"; + + //2.创建新的数据验证类 + DataTable dataTable = SQL.DBhelper.Query(sql); + //3.验证账号密码是否正确 + if (dataTable.Rows.Count > 0) + { + string updata = $"update MyUser set UserPwd='{newPwd}' where UserAccount='{account}' and UserPwd='{oldPwd}'"; + int result = SQL.DBhelper.NonQuery(updata); + if (result > 0) + { + int a = int.Parse(oldPwd); + int b = int.Parse(newPwd); + + Response.Write(""); + } + else + { + Response.Write(""); + } + + } + else + { + Response.Write(""); + } + } + + protected void Button2_Click(object sender, EventArgs e) + { + Response.Redirect("WebForm1.aspx"); + } + } +``` + +## 删除用户 + +### WebForm4.aspx + + + +```asp +
+ 删除用户: +
+``` + +### 后端 + + + +```c# +public partial class WebForm4 : System.Web.UI.Page + { + protected void Page_Load(object sender, EventArgs e) + { + + } + + protected void Button1_Click(object sender, EventArgs e) + { + string account = TextBox1.Text.Trim(); + string sql = $"select * from MyUser where UserAccount='{account}'"; + + DataTable dataTable= SQL.DBhelper.Query(sql); + + if (dataTable.Rows.Count>0) + { + string delete = $"delete from MyUser where UserAccount = '{account}'"; + DataTable dataTable1 = SQL.DBhelper.Query(delete); + if (dataTable1.Rows.Count == 0) + { + Response.Write(""); + } + else + { + Response.Write(""); + } + + } + else + { + Response.Write(""); + } + + } + } +``` +