From c4a48642c5004e8c57a15c39adf82a6ee7745b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E9=91=AB=E5=BC=BA?= <2559801285@qq.com> Date: Sun, 5 Jun 2022 14:53:01 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2015?= =?UTF-8?q?=E5=90=B4=E6=98=8E=E6=9D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6-\350\256\241\347\256\227\345\231\250.md" | 52 ------------------- 1 file changed, 52 deletions(-) delete mode 100644 "15\345\220\264\346\230\216\346\235\260/22-05-16-\350\256\241\347\256\227\345\231\250.md" 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 6a6315d..0000000 --- "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(); - } - } -``` - -- Gitee From c19b56f9c1f1ddd39250f8826aff9182856f91ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E9=91=AB=E5=BC=BA?= <2559801285@qq.com> Date: Sun, 5 Jun 2022 14:53:07 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=2038?= =?UTF-8?q?=E5=BC=A0=E9=9D=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "38\345\274\240\351\235\231/.keep" | 0 .../WebApplication1.sln" | 25 ------------------- 2 files changed, 25 deletions(-) delete mode 100644 "38\345\274\240\351\235\231/.keep" delete mode 100644 "38\345\274\240\351\235\231/WebApplication1.sln" 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 e69de29..0000000 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 2914581..0000000 --- "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 -- Gitee From 006e8258f3d6fb8c3e57ff738af152de237ecb76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E9=91=AB=E5=BC=BA?= <2559801285@qq.com> Date: Sun, 5 Jun 2022 22:58:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ASP.NET\344\275\234\344\270\232.md" | 369 ++++++++++++++++++ 1 file changed, 369 insertions(+) create mode 100644 "\347\224\260\351\221\253\345\274\272/ASP.NET\344\275\234\344\270\232.md" 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 0000000..9e77400 --- /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(""); + } + + } + } +``` + -- Gitee