📄 addbook.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Manager_addbook : System.Web.UI.Page
{
//全局变量
private static string connstr = "Server=localhost;Database=Materialsystem;User ID=sa";
SqlConnection stuinfoconn = new SqlConnection(connstr);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void showallbutton_Click(object sender, EventArgs e)
{
Response.Redirect("../Manager/Management.aspx");
}
protected void manageborrowbutton_Click(object sender, EventArgs e)
{
Response.Redirect("../Manager/borrowregister.aspx");
}
protected void managereturnbutton_Click(object sender, EventArgs e)
{
Response.Redirect("../Manager/returnregister.aspx");
}
protected void addbookbutton_Click(object sender, EventArgs e)
{
Response.Redirect("../Manager/addbook.aspx");
}
protected void logoutbutton_Click(object sender, EventArgs e)
{
Response.Redirect("../Login/Login.aspx");
}
protected void bookaddbutton_Click(object sender, EventArgs e)
{
SqlCommand testcomm = new SqlCommand("SELECT count(*) FROM Bookbaseinfo WHERE Booknum='" + booknumtextbox.Text.ToString().Trim() + "'", stuinfoconn);
if (stuinfoconn.State == ConnectionState.Closed)
{
stuinfoconn.Open();
int n = (int)testcomm.ExecuteScalar();
stuinfoconn.Close();
if (n > 0)
{
Response.Redirect("<script>alert('该货物已存在!');</script>");
}
else
{
int bookclass = Convert.ToInt16(DropDownList1.SelectedValue);
int state = 1;
SqlCommand insertbook = new SqlCommand("INSERT INTO Bookbaseinfo VALUES('" + booknumtextbox.Text.ToString().Trim() + "','" + booknametextbox.Text.ToString().Trim() + "','"+ bookclass +"','"+ state +"')", stuinfoconn);
stuinfoconn.Open();
insertbook.ExecuteNonQuery();
stuinfoconn.Close();
Response.Write("<script>alert('添加成功!');</script>");
}
}
}
protected void revbutton_Click(object sender, EventArgs e)
{
booknametextbox.Text = "";
booknumtextbox.Text = "";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -