addbook.aspx.cs

来自「具有仓库管理信息系统的基本功能。。入库」· CS 代码 · 共 71 行

CS
71
字号
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 + =
减小字号Ctrl + -
显示快捷键?