From d2f720ae94ce55b4b9f71ce89b3f950a6d4f83b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=96=B9=E6=A1=82=E9=BE=99?= <809725844@qq.com>
Date: Sun, 27 Jun 2021 07:56:15 +0000
Subject: [PATCH] ...
---
.../DLYM.aspx" | 38 ++++++++
.../DLYM.aspx.cs" | 50 +++++++++++
.../SQL.cs" | 44 +++++++++
.../XSYM.aspx" | 27 ++++++
.../XSYM.aspx.cs" | 81 +++++++++++++++++
.../ZCYM.aspx" | 89 +++++++++++++++++++
.../ZCYM.aspx.cs" | 55 ++++++++++++
7 files changed, 384 insertions(+)
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx.cs"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/SQL.cs"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx.cs"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx"
create mode 100644 "6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx.cs"
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx"
new file mode 100644
index 0000000..ac8247e
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx"
@@ -0,0 +1,38 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DLYM.aspx.cs" Inherits="WebApplication1.DLYM" %>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx.cs" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx.cs"
new file mode 100644
index 0000000..69e82cd
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/DLYM.aspx.cs"
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace WebApplication1
+{
+ public partial class DLYM : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ if (Response.Cookies["Name"]!=null)
+ {
+ UserName.Text = Response.Cookies["Name"].Value;
+ }
+ if (Response.Cookies["Pwd"] != null)
+ {
+ Password.Text = Response.Cookies["Pwd"].Value;
+ }
+ }
+ }
+
+ protected void DL_Click(object sender, EventArgs e)
+ {
+ string name = this.UserName.Text;
+ string pwd = this.Password.Text;
+ string sql = $"select * from UserInfo where username='{name}' and password='{pwd}'";
+ DataTable dataTable = SQL.Table(sql);
+ if (dataTable.Rows.Count > 0)
+ {
+ Response.Cookies["Name"].Value = name;
+ Response.Cookies["Name"].Expires = DateTime.Now.AddDays(3);
+ Response.Cookies["Pwd"].Value = pwd;
+ Response.Cookies["Pwd"].Expires = DateTime.Now.AddDays(3);
+ Response.Redirect("~/XSYM.aspx");
+ Response.Write("");
+ }
+ else
+ {
+ Response.Write("");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/SQL.cs" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/SQL.cs"
new file mode 100644
index 0000000..91ce673
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/SQL.cs"
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace WebApplication1
+{
+ public class SQL
+ {
+ static string connerSQL = "server=.;database=UserDB;uid=sa;pwd=123456;";
+ public static DataTable Table(string sql)
+ {
+ SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql, connerSQL);
+ DataTable table = new DataTable();
+ sqlDataAdapter.Fill(table);
+ return table;
+ }
+ public static int AffectSum(string sql)
+ {
+ int Sum = 0;
+ SqlConnection sqlConnection = null;
+ try
+ {
+ sqlConnection = new SqlConnection(connerSQL);
+ SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
+ sqlConnection.Open();
+ Sum = sqlCommand.ExecuteNonQuery();
+
+ }
+ catch (Exception)
+ {
+ return -1;
+ throw;
+ }
+ finally
+ {
+ sqlConnection.Close();
+ }
+ return Sum;
+ }
+ }
+}
\ No newline at end of file
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx"
new file mode 100644
index 0000000..9c2149a
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx"
@@ -0,0 +1,27 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="XSYM.aspx.cs" Inherits="WebApplication1.XSYM" %>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx.cs" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx.cs"
new file mode 100644
index 0000000..5b7a548
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/XSYM.aspx.cs"
@@ -0,0 +1,81 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace WebApplication1
+{
+ public partial class XSYM : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ Bind();
+ }
+ }
+ public void Bind()
+ {
+ string sql = "select * from UserInfo";
+ DataTable dataTable = SQL.Table(sql);
+ GridView1.DataSource = dataTable;
+ GridView1.DataKeyNames = new string[] { "id" };
+ GridView1.DataBind();
+ }
+
+ //编辑
+ protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
+ {
+ GridView1.EditIndex = e.NewEditIndex;
+ Bind();
+ }
+
+ //删除
+ protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
+ {
+ string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
+ string sql= $"delete from UserInfo where id={id}";
+ int Sum = SQL.AffectSum(sql);
+ if (Sum>0)
+ {
+ Response.Write("");
+ }
+ else
+ {
+ Response.Write("");
+ }
+ }
+
+ //更新
+ protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
+ {
+ string id = GridView1.Rows[e.RowIndex].Cells[0].Text;
+ string name = (GridView1.Rows[e.RowIndex].Cells[1].Controls[0] as TextBox).Text;
+ string pwd = (GridView1.Rows[e.RowIndex].Cells[2].Controls[0] as TextBox).Text;
+ string email = (GridView1.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox).Text;
+ string sql = $"update UserInfo set username='{name}',password='{pwd}',email='{email}' where id={id}";
+ int Sum = SQL.AffectSum(sql);
+ if (Sum>0)
+ {
+ Response.Write("");
+ }
+ else
+ {
+ Response.Write("");
+ }
+ GridView1.EditIndex = -1;
+ Bind();
+ }
+
+ //取消
+ protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
+ {
+ GridView1.EditIndex = -1;
+ Bind();
+ }
+ }
+}
\ No newline at end of file
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx"
new file mode 100644
index 0000000..d66d034
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx"
@@ -0,0 +1,89 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ZCYM.aspx.cs" Inherits="WebApplication1.ZCYM" %>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git "a/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx.cs" "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx.cs"
new file mode 100644
index 0000000..4c184bf
--- /dev/null
+++ "b/6-21 WebForm\347\254\254\345\233\233\346\254\241\344\275\234\344\270\232_Post&Get\344\274\240\350\276\223/ZCYM.aspx.cs"
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace WebApplication1
+{
+ public partial class ZCYM : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
+ }
+
+ protected void TJ_Click(object sender, EventArgs e)
+ {
+ string name = this.UserName.Text;
+ string pwd = this.Pwd1.Text;
+ int sex = int.Parse(this.Sex.SelectedValue);
+ string email = this.Email.Text;
+ string intro = this.Intro.Text;
+ string head_image = "~/Img/" + Head.FileName;
+ int roleName = int.Parse(this.RoleName.SelectedValue);
+ int isEnable = int.Parse(this.IsEnable.SelectedValue);
+
+ string sql = $"select * from UserInfo where username='{name}'";
+
+ DataTable dataTable = SQL.Table(sql);
+ if (dataTable.Rows.Count>0)
+ {
+ Response.Write("");
+ }
+ else
+ {
+ string insertSql = $"insert into UserInfo(username,password,sex,email,intro,head_image,roleName,isEnable)" +
+ $"values('{name}','{pwd}','{sex}','{email}','{intro}','{head_image}','{roleName}','{isEnable}') ";
+ int Sum = SQL.AffectSum(insertSql);
+ if (Sum > 0)
+ {
+ Response.Cookies["Name"].Value = name;
+ Response.Redirect("~/XSYM.aspx");
+ Response.Write("");
+ }
+ else
+ {
+ Response.Write("");
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--
Gitee