예제 #1
0
        public void bindReaderInfo()
        {
            string        ReaderBarCode = readerBarCode.Text;                                                        //获取读者编号
            string        readerSql     = "select * from tb_readerInfo where readerBarCode='" + ReaderBarCode + "'"; //定义查询读者语句
            SqlDataReader sdr           = DataOperate.GetRow(readerSql);                                             //获取读者详细信息

            if (sdr.Read())                                                                                          //读取一条记录
            {
                readerName.Text      = sdr["readerName"].ToString();                                                 //显示读者姓名
                sex.Text             = sdr["sex"].ToString();                                                        //显示读者性别
                certificateType.Text = sdr["certificateType"].ToString();                                            //显示证件类型
                certificateID.Text   = sdr["certificateID"].ToString();                                              //显示证件号
                string Money = sdr["money"].ToString();
                money.Text = Money.Substring(0, Money.Length - 2);                                                   //可用余额

                //创建SQL语句在读者类型表中查询符合读者类型编号的记录
                string        readerTypeSql = "select * from tb_readerType where readerTypeId=" + sdr["readerType"].ToString();
                SqlDataReader typeSdr       = DataOperate.GetRow(readerTypeSql); //获取读者类型信息
                typeSdr.Read();                                                  //读取一条记录
                readerType.Text = typeSdr["readerTypeName"].ToString();          //显示读者类型

                int    Num        = Convert.ToInt32(typeSdr["num"]);             //获取可借图书总数                                                                           //创建SQL语句在图书借阅表中查询符合读者编号条件的读者已借未还图书数
                string selSql     = "select count(*) from tb_bookBorrow where readerBarCode='" + ReaderBarCode + "' ";
                int    alreadyNum = DataOperate.SeleSQL(selSql);                 //获取图书已借未还数
                borrowCount.Text = Convert.ToString(Num - alreadyNum);           //显示还可以借阅数
                findbook.Enabled = true;
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('读者编号输入错误!')</script>");
            }
        }
예제 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string BookBarcode = bookBarCode.Text;               //获取图书条形码信息
            string BookName    = bookName.Text;                  //获取图书名称信息
            string BookType    = bookType.SelectedValue;         //获取图书类型信息
            string BookCase    = bookCase.SelectedValue;         //获取书架信息
            string Author      = author.Text;                    //获取图书作者信息
            string Price       = price.Text;                     //获取图书价格信息
            string Stock       = stock.Text;
            string BorrowSum   = borrowSum.Text;
            string Operator    = Session["userName"].ToString();
            string sql         = "";

            if (barcode == "add")
            {
                sql = "insert into tb_bookInfo values('" + BookBarcode + "','" + BookName + "'," + BookType + ",'" + BookCase + "','" + Author + "'," + Price + ",'" + Stock + "'," + BorrowSum + ",'" + Operator + "')";
            }
            else
            {
                sql = "update tb_bookInfo set bookName='" + BookName + "', bookType='" + BookType + "',bookCase='" + BookCase + "', author='" + Author + "',price='" + Price + "',stock='" + Stock + "',borrowSum='" + BorrowSum + "', operator='" + Operator + "'where bookBarCode='" + barcode + "'";
            }

            if (DataOperate.ExecSQL(sql))
            {
                Response.Write("<script language=javascript>alert('保存成功!');window.opener.location.href=window.opener.location='BookInfo.aspx';window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败!')</script>");
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string sql  = "";
            int    item = searchItem.SelectedIndex;

            switch (item)
            {
            case 0:
                sql = "select * from tb_bookInfo where bookBarCode like " + target.Text;
                break;

            case 1:
                sql = "select * from tb_bookInfo where bookName like '" + target.Text + "'";
                break;

            case 2:
                sql = "select * from tb_bookInfo where bookType like " + target.Text;
                break;

            case 3:
                sql = "select * from tb_bookInfo where bookCase like '" + target.Text + "'";
                break;

            case 4:
                sql = "select * from tb_bookInfo where author like '" + target.Text + "'";
                break;
            }
            gvBookInfo.DataSource   = DataOperate.GetDataset(sql, "tb_bookInfo");
            gvBookInfo.DataKeyNames = new string[] { "bookBarCode" };
            gvBookInfo.DataBind();
        }
예제 #4
0
 protected void btnBookSearch_Click(object sender, EventArgs e)
 {
     if (Convert.ToInt32(borrowCount.Text.Trim()) > 0)                           //判断读者是否还可以借书
     {
         if (bookBarCode.Text.Trim() != "")                                      //判断图书条形码是否为空
         {
             string  BookBarCode = bookBarCode.Text;                             //获取图书条形码
             string  sql         = "select * from tb_bookBorrow left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode left join tb_bookType on tb_bookInfo.bookType = tb_bookType.bookTypeID left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode where tb_bookBorrow.bookBarCode='" + BookBarCode + "'and tb_bookBorrow.readerBarCode='" + readerBarCode.Text + "'";
             DataSet ds          = DataOperate.GetDataset(sql, "tb_bookBorrow"); //调用公共类中getDataSet方法,将查询结果返回给DataSet对象
             if (ds.Tables[0].Rows.Count > 0)                                    //查询结果非空
             {
                 gvBookReturn.DataSource   = ds;                                 //获取数据源
                 gvBookReturn.DataKeyNames = new string[] { "bookBarCode" };     //设置主键
                 gvBookReturn.DataBind();                                        //绑定GridView控件
             }
             else
             {
                 ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书条形码错误!')</script>");
             }
         }
         else
         {
             ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书条形码不能为空!')</script>");
         }
     }
     else
     {
         ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('借阅数量已满!不可以再借阅!')</script>");
     }
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string ReaderTypeID   = readerTypeID.Text;
            string ReaderTypeName = readerTypeName.Text;
            string Num            = num.Text;
            string sql            = "";

            if (typeid == "add")
            {
                sql = "insert into tb_readerType values(" + ReaderTypeID + ",'" + ReaderTypeName + "'," + Num + ")";
            }
            else
            {
                sql = "update tb_readerType set readerTypeID=" + ReaderTypeID + ", readerTypeName='" + ReaderTypeName + "',num=" + Num + " where readerTypeID='" + typeid + "'";;
            }

            if (DataOperate.ExecSQL(sql))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存成功');window.opener.location.href=window.opener.location='ReaderType.aspx';window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败')</script>");
            }
        }
예제 #6
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string sql  = "";
            int    item = searchItem.SelectedIndex;

            switch (item)
            {
            case 0:
                sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookBorrow.bookBarCode like '" + target.Text + "'";
                break;

            case 1:
                sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookInfo.bookName like '" + target.Text + "'";
                break;

            case 2:
                sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookBorrow.readerBarCode like '" + target.Text + "'";
                break;

            case 3:
                sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_readerInfo.readerName like '" + target.Text + "'";
                break;
            }
            gvBorrowInfo.DataSource   = DataOperate.GetDataset(sql, "tb_bookBorrow");
            gvBorrowInfo.DataKeyNames = new string[] { "bookBarCode" };
            gvBorrowInfo.DataBind();
        }
예제 #7
0
        public void bindReaderInfo()
        {
            string sql = "select * from tb_readerInfo";

            gvReaderInfo.DataSource   = DataOperate.GetDataset(sql, "tb_readerInfo");
            gvReaderInfo.DataKeyNames = new string[] { "readerBarCode" };
            gvReaderInfo.DataBind();
        }
예제 #8
0
        public void bindBookCase()
        {
            string sql = "select * from tb_bookCase";

            gvBookCase.DataSource   = DataOperate.GetDataset(sql, "tb_bookCase");
            gvBookCase.DataKeyNames = new string[] { "bookcaseID" };
            gvBookCase.DataBind();
        }
예제 #9
0
        public void bindReaderType()
        {
            string sql = "select * from tb_readerType";

            gvReaderType.DataSource   = DataOperate.GetDataset(sql, "tb_readerType");
            gvReaderType.DataKeyNames = new string[] { "readerTypeID" };
            gvReaderType.DataBind();
        }
예제 #10
0
        protected void gvBookBorrow_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string BookBarCode = gvBookBorrow.DataKeys[e.NewSelectedIndex].Value.ToString();                                                                                  //获取选中图书的条形码
                                                                                                                                                                              //定义查询语句,查询指定图书条形码的图书信息
            string        sql = "select * from tb_bookInfo as a inner join tb_bookType as b on a.bookType=b.bookTypeID where a.bookBarCode='" + BookBarCode + "'";
            SqlDataReader sdr = DataOperate.GetRow(sql);                                                                                                                      //获取图书信息

            sdr.Read();                                                                                                                                                       //读取一条记录
            if (Convert.ToInt32(sdr["stock"]) > 0)                                                                                                                            //判断图书是否还有库存
            {
                float Money = Convert.ToSingle(money.Text);                                                                                                                   //读者余额
                float Hire  = Convert.ToSingle(sdr["hire"].ToString());                                                                                                       //读书租金
                if (Money > Hire)                                                                                                                                             //读者余额大于该读书租金
                {
                    string sqlBookBorrow = "select count(*) from tb_bookBorrow where bookBarcode='" + bookBarCode.Text + "' and readerBarCode='" + readerBarCode.Text + "' "; //定义查询语句,查询该读者是否借阅此书
                    if (DataOperate.SeleSQL(sqlBookBorrow) == 0)                                                                                                              //调用公共类中seleSQL方法,指定数据不存在(读者当前未借此书)
                    {
                        int      BorrowDay      = Convert.ToInt32(sdr["borrowDay"]);                                                                                          //获取借阅天数
                        string   BorrowTime     = DateTime.Now.Date.ToShortDateString();                                                                                      //获取借阅日期
                        string   ReaderBarCode  = readerBarCode.Text;                                                                                                         //获取读者编号
                        string   BorrowOperator = Session["userName"].ToString();                                                                                             //获取借阅经办人
                        string   ReturnTime     = DateTime.Now.Date.AddDays(BorrowDay).ToShortDateString();                                                                   //获取应还日期
                        string[] sqlT           = new string[3];                                                                                                              //设置SQL语句数组
                                                                                                                                                                              //定义SQL语句,将图书借阅信息插入到图书借阅表中
                        sqlT[0] = "insert tb_bookBorrow values('" + BookBarCode + "','" + ReaderBarCode + "','" + BorrowTime + "','" + BorrowOperator + "','" + ReturnTime + "')";
                        //定义SQL语句,更新图的借阅次数和图书的库存数据
                        sqlT[1] = "update tb_bookInfo set borrowSum=borrowSum+1,stock=stock-1 where bookBarCode='" + BookBarCode + "'";
                        //定义SQL语句,更新读者的可用余额
                        sqlT[2] = "update tb_readerInfo set money=money-" + Hire + " where readerBarCode='" + ReaderBarCode + "'";
                        //调用公共类中的execTransaction方法执行事务
                        if (DataOperate.ExecTransaction(sqlT)) //事务执行成功
                        {
                            bindReaderInfo();                  //重新绑定读者信息
                            gvBookBorrow.DataSource = null;    //将数据源设置为空
                            gvBookBorrow.DataBind();           //重新绑定数据
                            bookBarCode.Text = "";             //将图书条形码文本框清空
                            ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('借阅成功!')</script>");
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('借阅失败!')</script>");
                        }
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('该读者已经借阅此图书,不可以再借阅!')</script>");
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('读者金额不足,不可以借阅图书!')</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书已没有库存,不可以借阅!')</script>");
            }
        }
예제 #11
0
        protected void gvReaderType_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id     = gvReaderType.DataKeys[e.RowIndex].Value.ToString();
            string sqlDel = "delete tb_readerType where readerTypeID='" + id + "'";

            DataOperate.ExecSQL(sqlDel);  //调用公共类中通用数据更新、插入和删除操作方法函数execSQL,删除此读者。
            bindReaderType();
            ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('删除成功')</script>");
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sql1 = "select top 5 * from tb_bookInfo order by borrowSum desc"; //设置SQL语句

            gvBookOrder.DataSource = DataOperate.GetDataset(sql1, "tb_bookInfo");    //获取图书信息数据源
            gvBookOrder.DataBind();

            string sql2 = "select tb_readerInfo.readerBarCode,tb_readerInfo.readerName,count(*) as borrowSum from tb_readerInfo inner join tb_bookBorrow on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode group by tb_readerInfo.readerBarCode,tb_readerInfo.readerName order by count(*) desc";

            gvReaderOrder.DataSource = DataOperate.GetDataset(sql2, "tb_readderInfo");    //获取图书信息数据源
            gvReaderOrder.DataBind();
        }
예제 #13
0
        public void bindLibrary()
        {
            string        sql = "select * from tb_libraryInfo where libraryBarCode = '1001'";
            SqlDataReader sdr = DataOperate.GetRow(sql);

            sdr.Read();
            libraryName.Text  = sdr["libraryName"].ToString();
            webSite.Text      = sdr["webSite"].ToString();
            unit.Text         = sdr["unit"].ToString();
            built.Text        = sdr["built"].ToString();
            introduction.Text = sdr["introduction"].ToString();
            address.Text      = sdr["address"].ToString();
            phone.Text        = sdr["phone"].ToString();
        }
예제 #14
0
        protected void gvBookReturn_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string   BookBarCode = gvBookReturn.DataKeys[e.NewSelectedIndex].Value.ToString();              //获取选中图书条形码
            DateTime ReturnDate  = Convert.ToDateTime(gvBookReturn.Rows[e.NewSelectedIndex].Cells[4].Text); //获取应还日期
            DateTime TodayDate   = DateTime.Now.Date;                                                       //获取当前日期
            TimeSpan ts          = TodayDate - ReturnDate;                                                  //计算超期天数
            int      daysDate    = ts.Days;
            //计算租金和滞纳金
            string strLagMoney = gvBookReturn.Rows[e.NewSelectedIndex].Cells[7].Text;
            int    LagMoney    = Convert.ToInt32(strLagMoney.Substring(0, strLagMoney.Length));
            string strHire     = gvBookReturn.Rows[e.NewSelectedIndex].Cells[6].Text;
            int    Hire        = Convert.ToInt32(strHire.Substring(0, strHire.Length));
            string hint        = "";

            string[] sqlT;
            int      i = 0;

            if (daysDate > 0)   //存在超期情况
            {
                sqlT = new string[3];
                //更新读者余额
                sqlT[i++] = "update tb_readerInfo set money=money - " + LagMoney * daysDate + " where readerBarCode = '" + readerBarCode.Text + "' ";
                hint      = "您的图书归还期已过" + daysDate + "天,将扣除滞纳金" + LagMoney * daysDate + "元。";
            }
            else  //存在超期情况
            {
                sqlT = new string[3];
                //更新读者余额
                sqlT[i++] = "update tb_readerInfo set money=money + " + Hire + " where readerBarCode = '" + readerBarCode.Text + "' ";
            }
            //定义SQL语句,更新图书库存数
            sqlT[i++] = "update tb_bookInfo set stock=stock+1 where bookBarCode='" + BookBarCode + "'";
            //定义SQL语句,删除借书记录
            sqlT[i] = "delete tb_bookBorrow where bookBarCode='" + BookBarCode + "' and  readerBarCode='" + readerBarCode.Text + "' ";
            //调用公共类中的execTransaction方法执行事务
            if (DataOperate.ExecTransaction(sqlT)) //事务执行成功
            {
                bindReaderInfo();                  //重新绑定读者信息
                gvBookReturn.DataSource = null;    //将数据源设置为空
                gvBookReturn.DataBind();           //重新绑定数据
                bookBarCode.Text = "";             //将图书条形码文本框清空
                //调用自定义方法显示已借阅未归还图书信息
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书归还成功!" + hint + "')</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书归还失败!')</script>");
            }
        }
예제 #15
0
 protected void update_Click(object sender, EventArgs e)
 {
     if (Session["entryType"].ToString() == "读者")
     {
         string        sql = "select * from tb_readerInfo where readerName='" + Session["userName"].ToString() + "'";
         SqlDataReader sdr = DataOperate.GetRow(sql);
         sdr.Read();
         if (pwd.Text == sdr["readerPassword"].ToString())
         {
             string upSql = "update tb_readerInfo set readerPassword='******' where readerName='" + Session["userName"].ToString() + "'";
             if (DataOperate.ExecSQL(upSql))
             {
                 ClientScript.RegisterStartupScript(GetType(), "Message", "<script>alert('密码修改成功!');window.location='Login.aspx';</script>");
             }
             else
             {
                 Response.Write("<script>alert('更新失败!')</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('原始密码输入错误')</script>");
         }
     }
     else
     {
         string        sql = "select * from tb_user where userName='******'";
         SqlDataReader sdr = DataOperate.GetRow(sql);
         sdr.Read();
         if (pwd.Text == sdr["userPwd"].ToString())
         {
             string upSql = "update tb_user set userPwd='" + newPwd.Text + "' where userName='******'";
             if (DataOperate.ExecSQL(upSql))
             {
                 ClientScript.RegisterStartupScript(GetType(), "Message", "<script>alert('密码修改成功');window.location='Login.aspx';</script>");
             }
             else
             {
                 Response.Write("<script>alert('更新失败!')</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('原始密码输入错误')</script>");
         }
     }
 }
예제 #16
0
        protected void gvReaderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string id     = gvReaderInfo.DataKeys[e.RowIndex].Value.ToString(); //获取读者编号
            string sqlSel = "select count(*) from tb_bookBorrow where readerBarcode='" + id + "'";

            //调用公共类中判断指定数据是否存在的方法函数seleSQL,判断该读者是否有未归还图书
            if (DataOperate.SeleSQL(sqlSel) > 0)
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('不可以删除该读者,该读者图书还未归还')</script>"); //提示有未还图书,不能删除。
            }
            else
            {
                string sqlDel = "delete tb_readerInfo where readerBarCode='" + id + "'";
                DataOperate.ExecSQL(sqlDel);  //调用公共类中通用数据更新、插入和删除操作方法函数execSQL,删除此读者。
                bindReaderInfo();
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('删除成功')</script>");
            }
        }
예제 #17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string BookTypeID   = bookTypeID.Text;
            string BookTypeName = bookTypeName.Text;
            string BorrowDay    = borrowDay.Text;
            string Hire         = hire.Text;
            string LagMoney     = lagMoney.Text;
            string sql          = "insert into tb_bookType values(" + BookTypeID + ",'" + BookTypeName + "'," + BorrowDay + "," + Hire + "," + LagMoney + ")";

            if (DataOperate.ExecSQL(sql))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存成功');window.opener.location.href=window.opener.location='BookType.aspx';window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败')</script>");
            }
        }
예제 #18
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string ReaderBarCode   = readerBarCode.Text;            //读者编号
            string ReaderPassword  = readerPassword.Text;           //登录密码
            string ReaderName      = readerName.Text;               //读者名称
            string Sex             = sex.SelectedValue;             //性别
            string ReaderType      = readerType.SelectedValue;      //读者类型
            string CertificateType = certificateType.SelectedValue; //证书类型
            string CertificateID   = certificateID.Text;            //证书编号
            string Tel             = tel.Text;                      //联系电话
            string Email           = email.Text;                    //Email地址
            string Remark          = remark.InnerText;              //备注
            double Addmoney;                                        //增加余额

            if (addMoney.Text == "")
            {
                Addmoney = 0;
            }
            else
            {
                Addmoney = Convert.ToDouble(addMoney.Text);
            }
            string Operator = Session["userName"].ToString();
            string sql      = "";

            if (barcode == "add")
            {
                sql = "insert into tb_readerInfo(readerBarCode,readerPassword,readerName,sex,readerType,certificateType,certificateID,tel,email,remark,money,Operator) values('" + ReaderBarCode + "','" + ReaderPassword + "','" + ReaderName + "','" + Sex + "','" + ReaderType + "','" + CertificateType + "','" + CertificateID + "','" + Tel + "','" + Email + "','" + Remark + "'," + Addmoney + ",'" + Operator + "')";
            }
            else
            {
                sql = "update tb_readerInfo set readerName='" + ReaderName + "', sex='" + Sex + "',readerType='" + ReaderType + "', certificateType='" + CertificateType + "',certificateID='" + CertificateID + "',tel='" + Tel + "',email='" + Email + "', remark='" + Remark + "',money=money+" + Addmoney + ",operator='" + Operator + "' where readerBarCode='" + barcode + "'";
            }

            if (DataOperate.ExecSQL(sql))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存成功');window.opener.location.href=window.opener.location='ReaderInfo.aspx';window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败')</script>");
            }
        }
예제 #19
0
        public static bool CheckPwd(string sql, string name, string pass)
        {
            SqlConnection con = DataOperate.CreateCon();                         //创建数据库连接

            con.Open();                                                          //打开数据库连接
            SqlCommand com = new SqlCommand(sql, con);                           //创建SqlCommand对象

            com.Parameters.Add(new SqlParameter("name", SqlDbType.VarChar, 50)); //设置参数类型
            com.Parameters["name"].Value = name;                                 //设置参数值
            com.Parameters.Add(new SqlParameter("pass", SqlDbType.VarChar, 50)); //设置参数类型
            com.Parameters["pass"].Value = pass;                                 //设置参数值
                                                                                 //判断验证用户名和密码是否正确,并返回布尔值
            if (Convert.ToInt32(com.ExecuteScalar()) > 0)                        //返回指定用户名和密码的记录数大于0,此用户名和密码正确。
            {
                con.Close();
                return(true);
            }
            else
            {
                con.Close();
                return(false);
            }
        }
예제 #20
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string LibraryName  = libraryName.Text;
            string WebSite      = webSite.Text;
            string Unit         = unit.Text;
            string Built        = built.Text;
            string Introduction = introduction.Text;
            string Address      = address.Text;
            string Phone        = phone.Text;
            string sql          = "update tb_libraryInfo set libraryName='" + LibraryName + "', webSite='" + WebSite + "',unit='" + Unit + "', built='" + Built + "',introduction='" + Introduction + "',address='" + Address + "',phone='" + Phone + "' where libraryBarCode=" + "'1001'";

            if (DataOperate.ExecSQL(sql))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存成功')</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败')</script>");
            }
            Save.Enabled        = false;
            Update.Enabled      = true;
            libraryName.Enabled = webSite.Enabled = unit.Enabled = built.Enabled = calendarImg.Enabled = Calendar.Enabled = introduction.Enabled = address.Enabled = phone.Enabled = false;
        }
예제 #21
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string BookcaseID   = bookcaseID.Text;
            string BookcaseName = bookcaseName.Text;
            string sql          = "";

            if (caseId == "add")
            {
                sql = "insert into tb_bookCase values(" + BookcaseID + ",'" + BookcaseName + "')";
            }
            else
            {
                sql = "update tb_bookCase set bookcaseID=" + BookcaseID + ", bookcaseName='" + BookcaseName + "' where bookcaseID='" + caseId + "'";
            }

            if (DataOperate.ExecSQL(sql))
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存成功');window.opener.location.href=window.opener.location='BookCase.aspx';window.close();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('保存失败')</script>");
            }
        }