⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 return.aspx.cs

📁 具有仓库管理信息系统的基本功能。。入库
💻 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 Return : System.Web.UI.Page
{
    //全局变量
    private static string connstr = "Server=localhost;Database=Materialsystem;User ID=sa";
    SqlConnection stuinfoconn = new SqlConnection(connstr);
    SqlCommand mycomm = new SqlCommand();
    protected void Page_Load(object sender, EventArgs e)
    {
        welcomelable.Text = Session["studentname"].ToString();
        string stunum = Session["studentnumber"].ToString();
        string connstr = "Server=localhost;Database=Materialsystem;User ID=sa";
        string returnstr = "SELECT Borrownum as '出库序号',Booknum as '货物编号',Bookname as '货物名称',Bookclass as '货物类别',Borrowbookdate as '出库日期',Shouldreturnbookdate as '入库日期' FROM Borrowbook WHERE Snum='" + stunum + "'";
        SqlConnection returnconn = new SqlConnection(connstr);
        SqlDataAdapter returnadapter=new SqlDataAdapter(returnstr,returnconn);
        DataSet ds=new DataSet();
        returnadapter.Fill(ds,"returntable");
        bookview.DataSource=ds.Tables["returntable"].DefaultView;
        bookview.DataBind();
    }
    protected void mainpage_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Mainbody/BorrowReturn.aspx");
    }
    protected void personinfo_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Link/Myinfo.aspx");
    }
    protected void borrowbook_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Link/Borrow.aspx");
    }
    protected void returnbook_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Link/Return.aspx");
    }
    protected void history_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Link/BorrowHistory.aspx");
    }
    protected void changepwd_Click(object sender, EventArgs e)
    {
        Response.Redirect("../Link/ChangePwd.aspx");
    }
    protected void logout_Click(object sender, EventArgs e)
    {
        Session.Contents.Remove("studentname");
        Session.Contents.Remove("studentnum");
        Response.Redirect("../Login/Login.aspx");
    }
    protected void IsbnButton_Click(object sender, EventArgs e)
    {
        SqlDataReader mydata;
        string borrowbookstr = "SELECT Booknum as '货物编号',Bookname as '货物名称',Bookclass as '货物类别',State as '出入库清单' FROM Bookbaseinfo WHERE Booknum='" + IsbnTextBox.Text.ToString().Trim() + "'";
        mycomm.Connection = stuinfoconn;
        mycomm.CommandText = borrowbookstr;
        try
        {
            if (stuinfoconn.State == ConnectionState.Closed)
            {
                stuinfoconn.Open();
            }
            mydata = mycomm.ExecuteReader(CommandBehavior.CloseConnection);
            if (mydata.Read())
            {
                string booknum = mydata[0].ToString();
                string bookname = mydata[1].ToString();
                string bookclass = mydata[2].ToString();
                int state = Convert.ToInt16(mydata[3]);
                mydata.Close();
                //判断货物类别
                if (bookclass == "1")
                {
                    bookclass = "12号钢材";
                }
                else if (bookclass == "2")
                {
                    bookclass = "9#钢材";
                }
                else if (bookclass == "3")
                {
                    bookclass = "A4纸张";
                }
                else if (bookclass == "4")
                {
                    bookclass = "打印机墨盒";
                }

                if (state == 0)
                {
                    DateTime nowtime = DateTime.Now;
                    //发送入库申请,等候答复                
                    string stunum = Session["studentnumber"].ToString().Trim();
                    string addstr = "INSERT INTO Returnregister VALUES('" + stunum + "','" + booknum + "','" + bookname + "','" + bookclass + "','" + nowtime + "')";
                    SqlCommand insertbookinfo = new SqlCommand(addstr, stuinfoconn);
                    if (stuinfoconn.State == ConnectionState.Closed)
                    {
                        stuinfoconn.Open();
                    }
                    insertbookinfo.ExecuteNonQuery();
                    stuinfoconn.Close();
                    Response.Write("<script>alert('入库申请已发送,请等候管理员的答复!')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('您输错了货物编号,请对照右边的货物列表检查您的输入!');</script>");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (stuinfoconn.State == ConnectionState.Open)
            {
                stuinfoconn.Close();
            }
        }
    }
    protected void bookview_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        bookview.PageIndex = e.NewPageIndex;
        welcomelable.Text = Session["studentname"].ToString();
        string stunum = Session["studentnumber"].ToString();
        string connstr = "Server=localhost;Database=Materialsystem;User ID=sa";
        string returnstr = "SELECT Borrownum as '入库序号',Booknum as '货物编号',Bookname as '货物名称',Bookclass as '货物类别',Borrowbookdate as '出库日期',Shouldreturnbookdate as '入库日期' FROM Borrowbook WHERE Snum='" + stunum + "'";
        SqlConnection returnconn = new SqlConnection(connstr);
        SqlDataAdapter returnadapter = new SqlDataAdapter(returnstr, returnconn);
        DataSet ds = new DataSet();
        returnadapter.Fill(ds, "returntable");
        bookview.DataSource = ds.Tables["returntable"].DefaultView;
        bookview.DataBind();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -