图书管理登陆部分代码


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Login : System.Web.UI.Page
{
    static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";
    SqlConnection conn = new SqlConnection(strconn);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
            string sqlVistor = "SELECT COUNT(*) FROM ip";
            OpenConnection();
            SqlCommand cmdVistor = conn.CreateCommand();
            cmdVistor.CommandText = sqlVistor;
            SqlDataReader readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            //显示访问数量

            if (readerForVisitor.HasRows)
            {
                string visitor="";
               string numberVisited= readerForVisitor[0].ToString();


               for (int i = 0; i <numberVisited.Length; i++)
               {
                   visitor += numberVisited.Substring(i, 1);
                   TotoalVisitor.InnerHtml = "您是第" + returnImage(visitor)+"位访客";
                }
               
            }
            CloseConnection();
            readerForVisitor.Close();
            OpenConnection();
            TimeSpan span = new TimeSpan();
            sqlVistor = "SELECT* FROM ip WHERE ip='" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "' ORDER BY id DESC"; ;
            cmdVistor.CommandText = sqlVistor;
            readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            if (readerForVisitor.HasRows)
            {
                readerForVisitor.Read();
                DateTime now;
                now = DateTime.Now;
                //一分钟内再次访问,标记为灌水
                DateTime past = DateTime.Parse(readerForVisitor["time"].ToString());
                span = now.Subtract(past);
                if (span.TotalSeconds <= 60)
                {
                    message.InnerHtml = "欢迎再次光临,禁止灌水...";

                    return;
                }

            }
            CloseConnection();

            //增加访问量
            OpenConnection();
            string insertSQL = "INSERT INTO ip(ip,time) values('" +
            Request.ServerVariables["REMOTE_ADDR"].ToString() + "','" + DateTime.Now.ToString() + "')";

           
            cmdVistor.CommandText = insertSQL;
            try
            {

                cmdVistor.ExecuteNonQuery();

            }
            catch
            {

                message.InnerHtml = "服务器错误!";

            }
            CloseConnection();
        }
                   
    }
       //登陆对话框
    protected void btnLogin_Click(object sender, EventArgs e)
    {

        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text+"'";
            SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();
   
        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                //输入验证码后进入系统
                //注意,要想访问图文验证控件,必须在HTML设计器加如下代码
                //<asp:Image ID="imageValidate" runat="server" ImageUrl="~/Picture.aspx" />
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
            }
            else
            {
               Label.Text = "密码不正确,请重新输入!";
            }
 
        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }

     
    }

    void CloseConnection()
    {
     
        if (conn.State == ConnectionState.Open)
        {
            conn.Close();
        }
    }
    void OpenConnection()
    {
          if (conn == null)
            conn = new SqlConnection();
          if (conn.State == ConnectionState.Closed)
              conn.Open();
    }
     
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {
          
            Response.Redirect("Default.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
    }
    protected void BtnManager_Click(object sender, EventArgs e)
    {
        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text + "'";
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                     //图文验证码
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Manager.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
     
            }
            else
            {
                Label.Text = "密码不正确,请重新输入!";
            }

        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }


    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {

            Response.Redirect("Manager.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
     
    }
    private string returnImage(string number)
    {
        string showTotal = "";
        for (int i = 0; i < number.Length; i++)
        {
            switch (number[i].ToString())
            {
                case "1":
                    showTotal += "<img alt='lib' src='image/1.gif' style='width: 39px; height: 39px' />";
                    break;
                case "2":
                    showTotal += "<img alt='lib' src='image/2.gif' style='width: 39px; height: 39px' />";
                    break;
                case "3":
                    showTotal += "<img alt='lib' src='image/3.gif' style='width: 39px; height: 39px' />";
                    break;
                case "4":
                    showTotal += "<img alt='lib' src='image/4.gif' style='width: 39px; height: 39px' />";
                    break;
                case "5":
                    showTotal += "<img alt='lib' src='image/5.gif' style='width: 39px; height: 39px' />";
                    break;
                case "6":
                    showTotal += "<img alt='lib' src='image/6.gif' style='width: 39px; height: 39px' />";
                    break;
                case "7":
                    showTotal += "<img alt='lib' src='image/7.gif' style='width: 39px; height: 39px' />";
                    break;
                case "8":
                    showTotal += "<img alt='lib' src='image/8.gif' style='width: 39px; height: 39px' />";
                    break;
                case "9":
                    showTotal += "<img alt='lib' src='image/9.gif' style='width: 39px; height: 39px' />";
                    break;
                 default:
                    showTotal += "<img alt='lib' src='image/0.gif' style='width: 39px; height: 39px' />";
                    break;
            }
        }
        return showTotal;
    }

}


















using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Login : System.Web.UI.Page
{
    static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";
    SqlConnection conn = new SqlConnection(strconn);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
            string sqlVistor = "SELECT COUNT(*) FROM ip";
            OpenConnection();
            SqlCommand cmdVistor = conn.CreateCommand();
            cmdVistor.CommandText = sqlVistor;
            SqlDataReader readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            //显示访问数量

            if (readerForVisitor.HasRows)
            {
                string visitor="";
               string numberVisited= readerForVisitor[0].ToString();


               for (int i = 0; i <numberVisited.Length; i++)
               {
                   visitor += numberVisited.Substring(i, 1);
                   TotoalVisitor.InnerHtml = "您是第" + returnImage(visitor)+"位访客";
                }
               
            }
            CloseConnection();
            readerForVisitor.Close();
            OpenConnection();
            TimeSpan span = new TimeSpan();
            sqlVistor = "SELECT* FROM ip WHERE ip='" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "' ORDER BY id DESC"; ;
            cmdVistor.CommandText = sqlVistor;
            readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            if (readerForVisitor.HasRows)
            {
                readerForVisitor.Read();
                DateTime now;
                now = DateTime.Now;
                //一分钟内再次访问,标记为灌水
                DateTime past = DateTime.Parse(readerForVisitor["time"].ToString());
                span = now.Subtract(past);
                if (span.TotalSeconds <= 60)
                {
                    message.InnerHtml = "欢迎再次光临,禁止灌水...";

                    return;
                }

            }
            CloseConnection();

            //增加访问量
            OpenConnection();
            string insertSQL = "INSERT INTO ip(ip,time) values('" +
            Request.ServerVariables["REMOTE_ADDR"].ToString() + "','" + DateTime.Now.ToString() + "')";

           
            cmdVistor.CommandText = insertSQL;
            try
            {

                cmdVistor.ExecuteNonQuery();

            }
            catch
            {

                message.InnerHtml = "服务器错误!";

            }
            CloseConnection();
        }
                   
    }
       //登陆对话框
    protected void btnLogin_Click(object sender, EventArgs e)
    {

        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text+"'";
            SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();
   
        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                //输入验证码后进入系统
                //注意,要想访问图文验证控件,必须在HTML设计器加如下代码
                //<asp:Image ID="imageValidate" runat="server" ImageUrl="~/Picture.aspx" />
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
            }
            else
            {
               Label.Text = "密码不正确,请重新输入!";
            }
 
        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }

     
    }

    void CloseConnection()
    {
     
        if (conn.State == ConnectionState.Open)
        {
            conn.Close();
        }
    }
    void OpenConnection()
    {
          if (conn == null)
            conn = new SqlConnection();
          if (conn.State == ConnectionState.Closed)
              conn.Open();
    }
     
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {
          
            Response.Redirect("Default.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
    }
    protected void BtnManager_Click(object sender, EventArgs e)
    {
        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text + "'";
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                     //图文验证码
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Manager.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
     
            }
            else
            {
                Label.Text = "密码不正确,请重新输入!";
            }

        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }


    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {

            Response.Redirect("Manager.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
     
    }
    private string returnImage(string number)
    {
        string showTotal = "";
        for (int i = 0; i < number.Length; i++)
        {
            switch (number[i].ToString())
            {
                case "1":
                    showTotal += "<img alt='lib' src='image/1.gif' style='width: 39px; height: 39px' />";
                    break;
                case "2":
                    showTotal += "<img alt='lib' src='image/2.gif' style='width: 39px; height: 39px' />";
                    break;
                case "3":
                    showTotal += "<img alt='lib' src='image/3.gif' style='width: 39px; height: 39px' />";
                    break;
                case "4":
                    showTotal += "<img alt='lib' src='image/4.gif' style='width: 39px; height: 39px' />";
                    break;
                case "5":
                    showTotal += "<img alt='lib' src='image/5.gif' style='width: 39px; height: 39px' />";
                    break;
                case "6":
                    showTotal += "<img alt='lib' src='image/6.gif' style='width: 39px; height: 39px' />";
                    break;
                case "7":
                    showTotal += "<img alt='lib' src='image/7.gif' style='width: 39px; height: 39px' />";
                    break;
                case "8":
                    showTotal += "<img alt='lib' src='image/8.gif' style='width: 39px; height: 39px' />";
                    break;
                case "9":
                    showTotal += "<img alt='lib' src='image/9.gif' style='width: 39px; height: 39px' />";
                    break;
                 default:
                    showTotal += "<img alt='lib' src='image/0.gif' style='width: 39px; height: 39px' />";
                    break;
            }
        }
        return showTotal;
    }

}


















using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Login : System.Web.UI.Page
{
    static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";
    SqlConnection conn = new SqlConnection(strconn);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
            string sqlVistor = "SELECT COUNT(*) FROM ip";
            OpenConnection();
            SqlCommand cmdVistor = conn.CreateCommand();
            cmdVistor.CommandText = sqlVistor;
            SqlDataReader readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            //显示访问数量

            if (readerForVisitor.HasRows)
            {
                string visitor="";
               string numberVisited= readerForVisitor[0].ToString();


               for (int i = 0; i <numberVisited.Length; i++)
               {
                   visitor += numberVisited.Substring(i, 1);
                   TotoalVisitor.InnerHtml = "您是第" + returnImage(visitor)+"位访客";
                }
               
            }
            CloseConnection();
            readerForVisitor.Close();
            OpenConnection();
            TimeSpan span = new TimeSpan();
            sqlVistor = "SELECT* FROM ip WHERE ip='" + Request.ServerVariables["REMOTE_ADDR"].ToString() + "' ORDER BY id DESC"; ;
            cmdVistor.CommandText = sqlVistor;
            readerForVisitor = cmdVistor.ExecuteReader();
            readerForVisitor.Read();
            if (readerForVisitor.HasRows)
            {
                readerForVisitor.Read();
                DateTime now;
                now = DateTime.Now;
                //一分钟内再次访问,标记为灌水
                DateTime past = DateTime.Parse(readerForVisitor["time"].ToString());
                span = now.Subtract(past);
                if (span.TotalSeconds <= 60)
                {
                    message.InnerHtml = "欢迎再次光临,禁止灌水...";

                    return;
                }

            }
            CloseConnection();

            //增加访问量
            OpenConnection();
            string insertSQL = "INSERT INTO ip(ip,time) values('" +
            Request.ServerVariables["REMOTE_ADDR"].ToString() + "','" + DateTime.Now.ToString() + "')";

           
            cmdVistor.CommandText = insertSQL;
            try
            {

                cmdVistor.ExecuteNonQuery();

            }
            catch
            {

                message.InnerHtml = "服务器错误!";

            }
            CloseConnection();
        }
                   
    }
       //登陆对话框
    protected void btnLogin_Click(object sender, EventArgs e)
    {

        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text+"'";
            SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();
   
        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                //输入验证码后进入系统
                //注意,要想访问图文验证控件,必须在HTML设计器加如下代码
                //<asp:Image ID="imageValidate" runat="server" ImageUrl="~/Picture.aspx" />
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Default.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
            }
            else
            {
               Label.Text = "密码不正确,请重新输入!";
            }
 
        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }

     
    }

    void CloseConnection()
    {
     
        if (conn.State == ConnectionState.Open)
        {
            conn.Close();
        }
    }
    void OpenConnection()
    {
          if (conn == null)
            conn = new SqlConnection();
          if (conn.State == ConnectionState.Closed)
              conn.Open();
    }
     
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {
          
            Response.Redirect("Default.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
    }
    protected void BtnManager_Click(object sender, EventArgs e)
    {
        CloseConnection();
        string SQL = "SELECT * FROM LogInfor where username='" + TextBoxUserName.Text + "'";
        SqlCommand cmd = conn.CreateCommand();
        cmd.CommandText = SQL;
        OpenConnection();
        SqlDataReader reader = cmd.ExecuteReader();

        if (reader.HasRows)
        {
            reader.Read();//读取第一条记录
            if (reader["password"].ToString() == TextBoxPassword.Text)
            {
                Label.Text = "登陆成功,请输入验证码";
                     //图文验证码
                if (check.Text.ToString() == Session["check"].ToString())
                {

                    Response.Redirect("Manager.aspx");
                }
                else
                {
                    Label.Text = "验证码不正确,请重新输入";
                }
     
            }
            else
            {
                Label.Text = "密码不正确,请重新输入!";
            }

        }
        else
        {
            Label.Text = "用户名不正确,请重新输入!";
        }


    }
    protected void btnChange_Click(object sender, EventArgs e)
    {
        if (check.Text.ToString() == Session["check"].ToString())
        {

            Response.Redirect("Manager.aspx");
        }
        else
        {
            Label.Text = "验证码不正确,请重新输入";
        }
     
    }
    private string returnImage(string number)
    {
        string showTotal = "";
        for (int i = 0; i < number.Length; i++)
        {
            switch (number[i].ToString())
            {
                case "1":
                    showTotal += "<img alt='lib' src='image/1.gif' style='width: 39px; height: 39px' />";
                    break;
                case "2":
                    showTotal += "<img alt='lib' src='image/2.gif' style='width: 39px; height: 39px' />";
                    break;
                case "3":
                    showTotal += "<img alt='lib' src='image/3.gif' style='width: 39px; height: 39px' />";
                    break;
                case "4":
                    showTotal += "<img alt='lib' src='image/4.gif' style='width: 39px; height: 39px' />";
                    break;
                case "5":
                    showTotal += "<img alt='lib' src='image/5.gif' style='width: 39px; height: 39px' />";
                    break;
                case "6":
                    showTotal += "<img alt='lib' src='image/6.gif' style='width: 39px; height: 39px' />";
                    break;
                case "7":
                    showTotal += "<img alt='lib' src='image/7.gif' style='width: 39px; height: 39px' />";
                    break;
                case "8":
                    showTotal += "<img alt='lib' src='image/8.gif' style='width: 39px; height: 39px' />";
                    break;
                case "9":
                    showTotal += "<img alt='lib' src='image/9.gif' style='width: 39px; height: 39px' />";
                    break;
                 default:
                    showTotal += "<img alt='lib' src='image/0.gif' style='width: 39px; height: 39px' />";
                    break;
            }
        }
        return showTotal;
    }

}






















登陆部分:   using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient;  public partial class Login : System.Web.UI.Page {     static string strconn = "Data Source=localhost;database=BOOKS;integrated security=SSPI";     SqlConnection conn = new SqlConnection(strconn);     protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {               string sqlVistor = "SELECT COUNT(*) FROM ip";             OpenConnection();             SqlCommand cmdVistor = conn.CreateCommand();             cmdVistor.CommandText = sqlVistor;             SqlDataReader readerForVisitor = cmdVistor.ExecuteReader();             readerForVisitor.Read();             //显示访问数量              if (readerForVisitor.HasRows)             {                 string visitor="";                string numberVisited= readerForVisitor[0].ToString();                  for (int i = 0; i 













































系统功能与特色: (1)图书类别信息管理:作为一个学校的图书馆,涉及到的图书是很多的,这就有必要对图书进行分门别类,这样有利于对图书的查询和管理。不同的图书类别可以借阅的天数也是不一样的,管理员登陆系统后可以对图书类别进行添加,更新和删除操作。 (2)图书信息管理:当管理员对图书类别信息添加完成后,就可以开始进行图书信息的录入了,只有将图书馆拥有的图书录入系统中,读者朋友在登陆系统后才可以查询到自己喜欢的该图书。 (3)读者类别管理:为了方便图书馆的管理,系统对读者的类别进行了分别,不同的读者类别可以借阅图书的数目是不一样的。管理员在登陆系统后可以这个读者类别信息进行管理,包括添加读者类别信息,修改读者类别,删除读者类别,特别是执行删除操作时需要保持数据库表数据之间的一致性。 (4)读者信息管理:当管理员把读者类别信息编辑好完成后,就可以办理读者信息了,管理员可以添加新的读者信息,修改已经存在的读者信息,删除读者信息。 (5)图书借阅管理:读者可以登陆系统查询自己喜欢的图书,然后到图书馆进行图书借书的登记操作,当读者看完了书或需要归还时,需要拿着自己的图书到图书馆进行归还,此时有管理员办理图书归还业务。当然,如果读者借阅了图书因某种原因忘记了归还,管理员还可以对这些信息进行统计,同时,管理员还可以对已经出借的图书进行续借的办理。 (6)系统设置: 管理员登陆系统后可以修改图书馆的信息,可以修改管理其他操作员的信息,可以管理书架信息。 (7)口令更改:无论是管理员或读者身份登陆系统后,都可以对自己的登陆密码进行修改操作,这样保证了系统的安全性。 (8)系统特点:采用MVC设计模式,完全采用面向对象的设计思想,使用了开源框架Struts。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值