예제 #1
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            string bookCode = this.txtBookSer.Text.Trim();
            string readID   = this.readID.Text.Trim();

            if (string.IsNullOrEmpty(bookCode) || string.IsNullOrEmpty(readID))
            {
                MessageBox.Show(this, "图书编号或者读者编号不能为空");
            }
            YueDuLibrary.Model.BookInfo bookModel = BookInfo.GetModeBybookCode(bookCode);
            if (bookModel != null)
            {
                if (borrowandReturn.BackBook(readID, bookCode))
                {
                    bookModel.storage++;
                    BookInfo.Update(bookModel);
                    MessageBox.Show(this, "还书成功!");
                    DataSet ds = borrowandReturn.GetList2(" BorrowandReturn.ReaderID=" + readID);
                    GridView2.DataSource = ds;
                    GridView2.DataBind();
                }
                else
                {
                    MessageBox.Show(this, "还书失败!");
                }
            }
            else
            {
                MessageBox.Show(this, "该书不存在!");
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YueDuLibrary.Model.BookInfo DataRowToModel(DataRow row)
 {
     YueDuLibrary.Model.BookInfo model = new YueDuLibrary.Model.BookInfo();
     if (row != null)
     {
         if (row["bookId"] != null && row["bookId"].ToString() != "")
         {
             model.bookId = int.Parse(row["bookId"].ToString());
         }
         if (row["bookCode"] != null)
         {
             model.bookCode = row["bookCode"].ToString();
         }
         if (row["bookName"] != null)
         {
             model.bookName = row["bookName"].ToString();
         }
         if (row["typeId"] != null)
         {
             model.typeId = row["typeId"].ToString();
         }
         if (row["author"] != null)
         {
             model.author = row["author"].ToString();
         }
         if (row["price"] != null)
         {
             model.price = row["price"].ToString();
         }
         if (row["bookCaseId"] != null && row["bookCaseId"].ToString() != "")
         {
             model.bookCaseId = int.Parse(row["bookCaseId"].ToString());
         }
         if (row["bookPage"] != null && row["bookPage"].ToString() != "")
         {
             model.bookPage = int.Parse(row["bookPage"].ToString());
         }
         if (row["publish"] != null)
         {
             model.publish = row["publish"].ToString();
         }
         if (row["operId"] != null && row["operId"].ToString() != "")
         {
             model.operId = int.Parse(row["operId"].ToString());
         }
         if (row["storage"] != null && row["storage"].ToString() != "")
         {
             model.storage = int.Parse(row["storage"].ToString());
         }
         if (row["InCreateTime"] != null && row["InCreateTime"].ToString() != "")
         {
             model.InCreateTime = DateTime.Parse(row["InCreateTime"].ToString());
         }
         if (row["bookImg"] != null)
         {
             model.bookImg = row["bookImg"].ToString();
         }
     }
     return(model);
 }
예제 #3
0
        protected void btnBorrow_Click(object sender, EventArgs e)
        {
            string bookCode = this.txtBookSer.Text.Trim();

            YueDuLibrary.Model.BookInfo bookModel = BookInfo.GetModeBybookCode(bookCode);
            if (bookModel != null)
            {
                if (bookModel.storage > 0)
                {
                    bookModel.storage--;
                    BookInfo.Update(bookModel);
                    YueDuLibrary.Model.BorrowandReturn borrowandReturnModel = new Model.BorrowandReturn();
                    borrowandReturnModel.ReaderID = Convert.ToInt32(readID.Text);
                    borrowandReturnModel.BookCode = this.txtBookSer.Text.Trim();
                    borrowandReturn.Add(borrowandReturnModel);
                    MessageBox.Show(this, "借阅成功!");
                }
                else
                {
                    MessageBox.Show(this, "该书已经被借完!");
                }
            }
            else
            {
                MessageBox.Show(this, "暂无该书!");
            }
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(YueDuLibrary.Model.BookInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BookInfo set ");
            strSql.Append("bookCode=@bookCode,");
            strSql.Append("bookName=@bookName,");
            strSql.Append("typeId=@typeId,");
            strSql.Append("author=@author,");
            strSql.Append("price=@price,");
            strSql.Append("bookCaseId=@bookCaseId,");
            strSql.Append("bookPage=@bookPage,");
            strSql.Append("publish=@publish,");
            strSql.Append("operId=@operId,");
            strSql.Append("storage=@storage,");
            strSql.Append("InCreateTime=@InCreateTime,");
            strSql.Append("bookImg=@bookImg");
            strSql.Append(" where bookId=@bookId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@bookCode",     SqlDbType.VarChar,    15),
                new SqlParameter("@bookName",     SqlDbType.VarChar,    40),
                new SqlParameter("@typeId",       SqlDbType.VarChar,    30),
                new SqlParameter("@author",       SqlDbType.VarChar,    30),
                new SqlParameter("@price",        SqlDbType.VarChar,    10),
                new SqlParameter("@bookCaseId",   SqlDbType.Int,         4),
                new SqlParameter("@bookPage",     SqlDbType.Int,         4),
                new SqlParameter("@publish",      SqlDbType.VarChar,   100),
                new SqlParameter("@operId",       SqlDbType.Int,         4),
                new SqlParameter("@storage",      SqlDbType.Int,         4),
                new SqlParameter("@InCreateTime", SqlDbType.DateTime),
                new SqlParameter("@bookImg",      SqlDbType.VarChar,    60),
                new SqlParameter("@bookId",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.bookCode;
            parameters[1].Value  = model.bookName;
            parameters[2].Value  = model.typeId;
            parameters[3].Value  = model.author;
            parameters[4].Value  = model.price;
            parameters[5].Value  = model.bookCaseId;
            parameters[6].Value  = model.bookPage;
            parameters[7].Value  = model.publish;
            parameters[8].Value  = model.operId;
            parameters[9].Value  = model.storage;
            parameters[10].Value = model.InCreateTime;
            parameters[11].Value = model.bookImg;
            parameters[12].Value = model.bookId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(YueDuLibrary.Model.BookInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BookInfo(");
            strSql.Append("bookCode,bookName,typeId,author,price,bookCaseId,bookPage,publish,operId,storage,InCreateTime,bookImg)");
            strSql.Append(" values (");
            strSql.Append("@bookCode,@bookName,@typeId,@author,@price,@bookCaseId,@bookPage,@publish,@operId,@storage,@InCreateTime,@bookImg)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@bookCode",     SqlDbType.VarChar,    15),
                new SqlParameter("@bookName",     SqlDbType.VarChar,    40),
                new SqlParameter("@typeId",       SqlDbType.VarChar,    30),
                new SqlParameter("@author",       SqlDbType.VarChar,    30),
                new SqlParameter("@price",        SqlDbType.VarChar,    10),
                new SqlParameter("@bookCaseId",   SqlDbType.Int,         4),
                new SqlParameter("@bookPage",     SqlDbType.Int,         4),
                new SqlParameter("@publish",      SqlDbType.VarChar,   100),
                new SqlParameter("@operId",       SqlDbType.Int,         4),
                new SqlParameter("@storage",      SqlDbType.Int,         4),
                new SqlParameter("@InCreateTime", SqlDbType.DateTime),
                new SqlParameter("@bookImg",      SqlDbType.VarChar, 60)
            };
            parameters[0].Value  = model.bookCode;
            parameters[1].Value  = model.bookName;
            parameters[2].Value  = model.typeId;
            parameters[3].Value  = model.author;
            parameters[4].Value  = model.price;
            parameters[5].Value  = model.bookCaseId;
            parameters[6].Value  = model.bookPage;
            parameters[7].Value  = model.publish;
            parameters[8].Value  = model.operId;
            parameters[9].Value  = model.storage;
            parameters[10].Value = model.InCreateTime;
            parameters[11].Value = model.bookImg;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #6
0
 private void ShowInfo(int bookId)
 {
     YueDuLibrary.BLL.BookInfo   bll   = new YueDuLibrary.BLL.BookInfo();
     YueDuLibrary.Model.BookInfo model = bll.GetModel(bookId);
     this.lblbookId.Text   = model.bookId.ToString();
     this.txtbookCode.Text = model.bookCode;
     this.txtbookName.Text = model.bookName;
     //this.txttypeId.Text=model.typeId;
     this.txtauthor.Text = model.author;
     this.txtprice.Text  = model.price;
     //this.txtbookCaseId.Text=model.bookCaseId.ToString();
     this.txtbookPage.Text = model.bookPage.ToString();
     this.txtpublish.Text  = model.publish;
     //this.txtoperId.Text=model.operId.ToString();
     this.txtstorage.Text = model.storage.ToString();
     //this.txtInCreateTime.Text=model.InCreateTime.ToString();
     //this.txtbookImg.Text=model.bookImg;
 }
예제 #7
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            string txtBookSer = this.txtBookSer.Text.Trim();

            if (!string.IsNullOrEmpty(txtBookSer))
            {
                YueDuLibrary.Model.BookInfo booksModel = BookInfo.GetModeBybookCode(txtBookSer);
                if (booksModel != null)
                {
                    this.imgBookFace.ImageUrl = "UploadFiles/" + booksModel.bookImg;
                    labBookName.Text          = booksModel.bookName;
                    labAuthor.Text            = booksModel.author;
                    labPublish.Text           = booksModel.publish;
                    LabNum.Text            = booksModel.storage.ToString();
                    this.btnBorrow.Visible = true;
                }
                else
                {
                    MessageBox.Show(this, "该书未收录图书馆!");
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 通过bookCode得到一个对象实体
        /// </summary>
        public YueDuLibrary.Model.BookInfo GetModeBybookCode(string bookCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 bookId,bookCode,bookName,typeId,author,price,bookCaseId,bookPage,publish,operId,storage,InCreateTime,bookImg from BookInfo ");
            strSql.Append(" where bookCode=@bookCode");
            SqlParameter[] parameters =
            {
                new SqlParameter("@bookCode", SqlDbType.NVarChar, 15)
            };
            parameters[0].Value = bookCode;

            YueDuLibrary.Model.BookInfo model = new YueDuLibrary.Model.BookInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #9
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtbookCode.Text.Trim().Length == 0)
            {
                strErr += "图书编码不能为空!\\n";
            }
            if (this.txtbookName.Text.Trim().Length == 0)
            {
                strErr += "bookName不能为空!\\n";
            }

            if (this.txtauthor.Text.Trim().Length == 0)
            {
                strErr += "author不能为空!\\n";
            }
            if (this.txtprice.Text.Trim().Length == 0)
            {
                strErr += "price不能为空!\\n";
            }

            if (!PageValidate.IsNumber(txtbookPage.Text))
            {
                strErr += "bookPage格式错误!\\n";
            }
            if (this.txtpublish.Text.Trim().Length == 0)
            {
                strErr += "publish不能为空!\\n";
            }
            //if(!PageValidate.IsNumber(txtoperId.Text))
            //{
            //	strErr+="operId格式错误!\\n";
            //}

            //if(!PageValidate.IsDateTime(txtInCreateTime.Text))
            //{
            //	strErr+="InCreateTime格式错误!\\n";
            //}
            //if(this.txtbookImg.Text.Trim().Length==0)
            //{
            //	strErr+="封面上传不能为空!\\n";
            //}

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    bookId     = int.Parse(this.lblbookId.Text);
            string bookCode   = this.txtbookCode.Text;
            string bookName   = this.txtbookName.Text;
            string typeId     = this.ddlType.Text;
            string author     = this.txtauthor.Text;
            string price      = this.txtprice.Text;
            int    bookCaseId = int.Parse(this.ddlCase.Text);
            int    bookPage   = int.Parse(this.txtbookPage.Text);
            string publish    = this.txtpublish.Text;
            //int operId=int.Parse(this.txtoperId.Text);
            int storage = int.Parse(this.txtstorage.Text);
            //DateTime InCreateTime=DateTime.Parse(this.txtInCreateTime.Text);

            string bookImgName = BLL.tools.UploadFile(this.fupUpPic, 1, 5);

            if (bookImgName != "")
            {
                YueDuLibrary.Model.BookInfo model = new YueDuLibrary.Model.BookInfo();
                model.bookId     = bookId;
                model.bookCode   = bookCode;
                model.bookName   = bookName;
                model.typeId     = typeId;
                model.author     = author;
                model.price      = price;
                model.bookCaseId = bookCaseId;
                model.bookPage   = bookPage;
                model.publish    = publish;
                //model.operId=operId;
                model.storage = storage;
                //model.InCreateTime=InCreateTime;
                model.bookImg = bookImgName;

                YueDuLibrary.BLL.BookInfo bll = new YueDuLibrary.BLL.BookInfo();
                bll.Update(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
            }
        }
예제 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtbookCode.Text.Trim().Length == 0)
            {
                strErr += "bookCode不能为空!\\n";
            }
            if (this.txtbookName.Text.Trim().Length == 0)
            {
                strErr += "bookName不能为空!\\n";
            }

            if (this.txtauthor.Text.Trim().Length == 0)
            {
                strErr += "author不能为空!\\n";
            }
            if (this.txtprice.Text.Trim().Length == 0)
            {
                strErr += "price不能为空!\\n";
            }

            if (!PageValidate.IsNumber(txtbookPage.Text))
            {
                strErr += "bookPage格式错误!\\n";
            }
            if (this.txtpublish.Text.Trim().Length == 0)
            {
                strErr += "publish不能为空!\\n";
            }



            if (this.fupBookFace.FileName.Trim().Length == 0)
            {
                strErr += "请添加该书封面!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string bookCode   = this.txtbookCode.Text;
            string bookName   = this.txtbookName.Text;
            string typeId     = this.ddlType.Text;
            string author     = this.txtauthor.Text;
            string price      = this.txtprice.Text;
            int    bookCaseId = int.Parse(this.ddlBookCase.Text);
            int    bookPage   = int.Parse(this.txtbookPage.Text);
            string publish    = this.txtpublish.Text;

            int    storage     = int.Parse(this.txtstorage.Text);
            string bookImgName = BLL.tools.UploadFile(this.fupBookFace, 1, 5);

            if (bookImgName != "")
            {
                string bookImg = bookImgName;

                YueDuLibrary.Model.BookInfo model = new YueDuLibrary.Model.BookInfo();
                model.bookCode   = bookCode;
                model.bookName   = bookName;
                model.typeId     = typeId;
                model.author     = author;
                model.price      = price;
                model.bookCaseId = bookCaseId;
                model.bookPage   = bookPage;
                model.publish    = publish;

                model.storage = storage;

                model.bookImg = bookImg;

                YueDuLibrary.BLL.BookInfo bll = new YueDuLibrary.BLL.BookInfo();
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
            }
        }