Esempio n. 1
0
        //更新数据
        public bool Update(BorrowInfo entity)
        {
            string sql = @"update BorrowInfo set bookname=@bookname,useguid=@useguid,borrowperson=@borrowperson,
            handler=@handler,borrowcause=@borrowcause,borrowdate=@borrowdate,returndate=@returndate,remark=@remark where useguid=@useguid";

            SqlParameter[] pms = new SqlParameter[]
            {
                new SqlParameter("@bookname", entity.BookName),
                new SqlParameter("@useguid", entity.UseGuid),
                new SqlParameter("@borrowperson", entity.BorrowPerson),
                new SqlParameter("@handler", entity.Handler),
                new SqlParameter("@borrowcause", entity.BorrowCause),
                new SqlParameter("@borrowdate", entity.BorrowDate),
                new SqlParameter("@returndate", entity.ReturnDate),
                new SqlParameter("@remark", entity.Remark),
            };
            int r = SqlHelper.ExecuteNonQuery(sql, CommandType.Text, pms);

            if (r > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 保存借阅信息,同时更新图书可借库存
        /// </summary>
        /// <param name="objBorrowInfo">借书主表信息</param>
        /// <param name="borrowDetails">借书明细信息</param>
        /// <returns></returns>
        public bool AddBorrowInfo(BorrowInfo objBorrowInfo, List <BorrowDetail> borrowDetails)
        {
            List <string>         sqlList   = new List <string>();
            List <SqlParameter[]> paramList = new List <SqlParameter[]>();

            sqlList.Add("INSERT INTO BorrowInfo(BorrowId, ReaderId, AdminName_B) VALUES(@BorrowId, @ReaderId, @AdminName_B)");
            paramList.Add(new SqlParameter[]
            {
                new SqlParameter("@BorrowId", objBorrowInfo.BorrowId),
                new SqlParameter("@ReaderId", objBorrowInfo.ReaderId),
                new SqlParameter("@AdminName_B", objBorrowInfo.AdminName_B)
            });
            string detailSql = "INSERT INTO BorrowDetail (BorrowId, BookId, BorrowCount, NonReturnCount, Expire) VALUES(@BorrowId, @BookId, @BorrowCount, @NonReturnCount, @Expire)";
            string bookSql   = "UPDATE Books SET Remainder = Remainder - @BorrowCount WHERE BookId = @BookId";

            foreach (BorrowDetail item in borrowDetails)
            {
                sqlList.Add(detailSql);
                paramList.Add(new SqlParameter[]
                {
                    new SqlParameter("@BorrowId", item.BorrowId),
                    new SqlParameter("@BookId", item.BookId),
                    new SqlParameter("@BorrowCount", item.BorrowCount),
                    new SqlParameter("@NonReturnCount", item.NonReturnCount),
                    new SqlParameter("@Expire", item.Expire)
                });
                sqlList.Add(bookSql);
                paramList.Add(new SqlParameter[]
                {
                    new SqlParameter("@BorrowCount", item.BorrowCount),
                    new SqlParameter("@BookId", item.BookId)
                });
            }
            return(SqlHelper.UpdateByTran(sqlList, paramList));
        }
        /// <summary>
        /// 确认借书
        /// </summary>
        /// <param name="readingCare"></param>
        /// <returns></returns>
        public bool BorrowBookConfirm(BorrowInfo borrowInfo, List <BorrowDetail> details)
        {
            SqlParameter[] mainParam = new SqlParameter[]
            {
                new SqlParameter("@BorrowId", borrowInfo.BorrowId),
                new SqlParameter("@ReaderId", borrowInfo.ReaderId),
                new SqlParameter("@AdminName_B", borrowInfo.AdminName_B),
            };

            string sqlMain   = "insert into BorrowInfo(BorrowId,ReaderId,AdminName_B) values(@BorrowId,@ReaderId,@AdminName_B)";
            string sqlDetail = "insert into BorrowDetail(BorrowId,BookId,BorrowCount,NonReturnCount, Expire) values(@BorrowId,@BookId,@BorrowCount,@NonReturnCount,@Expire)";
            List <SqlParameter[]> detailParam = new List <SqlParameter[]>();

            foreach (BorrowDetail detail in details)
            {
                detailParam.Add(new SqlParameter[]
                {
                    new SqlParameter("@BorrowId", detail.BorrowId),
                    new SqlParameter("@BookId", detail.BookId),
                    new SqlParameter("@BorrowCount", detail.BorrowCount),
                    new SqlParameter("@NonReturnCount", detail.BorrowCount),
                    new SqlParameter("@Expire", detail.Expire),
                });
            }
            return(SqlHelper.ExecuteTransaction(sqlMain, mainParam, sqlDetail, detailParam));
        }
Esempio n. 4
0
        /// <summary>
        /// 插入指定的借贷信息
        /// </summary>
        /// zouql   16.08.30
        /// yangj   16.09.10    修改字段
        /// <param name="financeId">融资标识</param>
        /// <returns>操作结果</returns>
        public bool Add(int financeId)
        {
            // 获取融资信息
            var finance = FinanceMapper.Find(financeId);
            var review  = ReviewMapper.Find(financeId);

            // 获取产品信息
            var product = ProduceMapper.FindByProduce_Id(finance.ProduceId);

            // 实例化BorrowInfo
            var borrowInfo = new BorrowInfo()
            {
                FinanceId = financeId
            };

            // BorrowInfo赋值
            borrowInfo.ApprovalPrincipal = review.ApprovalPrincipal;
            borrowInfo.InterestRate      = product.InterestRate;
            borrowInfo.FinancingPeriods  = product.FinancingPeriods;
            borrowInfo.RepaymentInterval = product.RepaymentInterval;
            borrowInfo.RepaymentMethod   = product.RepaymentMethod;
            borrowInfo.RepaymentDate     = review.RepaymentDate;
            borrowInfo.FinanceAddDate    = FinanceMapper.FindAddDate(borrowInfo.FinanceId);
            borrowInfo.OncePayMonths     = finance.OncePayMonths.Value;
            borrowInfo.FinalRatio        = product.FinalRatio;
            borrowInfo.CustomerBailRatio = product.CustomerBailRatio;
            borrowInfo.FinalCost         = review.FinalCost;
            borrowInfo.ExtralCost        = product.AdditionalGPSCost + product.AdditionalOtherCost;

            return(BorrowMapper.Insert(borrowInfo) > 0);
        }
Esempio n. 5
0
        public ActionResult returnBook(int borrowId)
        {
            BorrowInfo info = db.BorrowInfo.Find(borrowId);  // 获取指定的借阅的数据
            Book       book = db.Books.Where(a => a.bookName == info.bookName).First();

            if (info == null)
            {
                return(Json("NoExit"));
            }
            TimeSpan day = DateTime.Now - db.BorrowInfo.Find(borrowId).borrowTime; // 计算借阅时间

            db.Configuration.ValidateOnSaveEnabled = false;
            if (day.Days > 30)
            {
                info.isBeyond = true;
                db.SaveChanges();
                db.Configuration.ValidateOnSaveEnabled = true;
                return(Json("ToLong"));
            }
            info.backTime      = DateTime.Now;
            book.number       += 1; // 同时增加库存和减少借阅数
            book.borrowNumber -= 1;
            db.SaveChanges();
            db.Configuration.ValidateOnSaveEnabled = true;
            return(RedirectToAction("BorrowInfoes", new { id = info.readerId }));
        }
Esempio n. 6
0
        //保存所有借阅信息
        public void SaveBorrowInfo()
        {
            ArrayList  arrayList  = (ArrayList)GetObject("data");
            BorrowInfo borrowInfo = new BorrowInfo();
            string     status     = GetString("status");

            foreach (var item in arrayList)
            {
                Hashtable i = (Hashtable)item;
                borrowInfo.BookName     = (string)i["BookName"];
                borrowInfo.UseGuid      = (string)i["UseGuid"];
                borrowInfo.BorrowPerson = (string)i["BorrowPerson"];
                borrowInfo.Handler      = (string)i["Handler"];
                borrowInfo.BorrowCause  = (string)i["BorrowCause"];
                borrowInfo.BorrowDate   = (DateTime)i["BorrowDate"];
                borrowInfo.ReturnDate   = (DateTime)i["ReturnDate"];
                borrowInfo.Remark       = (string)i["Remark"];
            }
            bool r = borrowInfoBLL.SaveBorrowInfo(borrowInfo, status);

            if (r)
            {
                RenderText("添加成功!");
            }
            else
            {
                RenderJson("添加失败!");
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存借书信息
        /// </summary>
        /// <param name="main"></param>
        /// <param name="detail"></param>
        /// <returns></returns>
        public bool BorrowBook(BorrowInfo main, List <BorrowDetail> detail)
        {
            //借书主表插入的Sql语句
            string mainSql = "insert into BorrowInfo (BorrowId,ReaderId,AdminName_B) values (@BorrowId,@ReaderId,@AdminName_B)";
            //借书明细表信息插入sql语句
            StringBuilder sb = new StringBuilder();

            sb.Append("insert into BorrowDetail (BorrowId,BookId,BorrowCount,ReturnCount,NonReturnCount,Expire)");
            sb.Append(" values(@BorrowId,@BookId,@BorrowCount,@ReturnCount,@NonReturnCount,@Expire)");

            //创建主表参数数组
            SqlParameter[] mainParam = new SqlParameter[] {
                new SqlParameter("@BorrowId", main.BorrowId),
                new SqlParameter("@ReaderId", main.ReaderId),
                new SqlParameter("@AdminName_B", main.AdminName_B)
            };

            //创建借阅详细表参数数组
            List <SqlParameter[]> detailParam = new List <SqlParameter[]>();

            foreach (BorrowDetail item in detail)
            {
                detailParam.Add(new SqlParameter[] {
                    new SqlParameter("@BorrowId", item.BorrowId),
                    new SqlParameter("@BookId", item.BookId),
                    new SqlParameter("@BorrowCount", item.BorrowCount),
                    new SqlParameter("@ReturnCount", item.ReturnCount),
                    new SqlParameter("@NonReturnCount", item.NonReturnCount),
                    new SqlParameter("@Expire", item.Expire),
                });
            }
            //启动事务提交多个对象
            return(SqlDB.updateByTran(mainSql, mainParam, sb.ToString(), detailParam));
        }
Esempio n. 8
0
        public ActionResult borrowBook(int readId, int bookId)
        {
            Book book = db.Books.Find(bookId);
            User user = db.Users.Find(readId);

            if (book == null)
            {
                return(Json("bookNoExist"));
            }
            else if (user == null)
            {
                return(Json("userNoExist"));
            }
            else if (book.number <= 0)
            {
                return(Json("noEnough"));
            }

            BorrowInfo info = new BorrowInfo(); // 新增借阅记录

            info.bookName   = book.bookName;
            info.readerId   = user.Id;
            info.borrowTime = DateTime.Now;
            info.isBeyond   = false;

            db.Configuration.ValidateOnSaveEnabled = false;
            book.number       -= 1; // 同时扣除库存和增加借阅数
            book.borrowNumber += 1;
            db.BorrowInfo.Add(info);
            db.SaveChanges();
            db.Configuration.ValidateOnSaveEnabled = true;
            return(Json("borrow_success"));
            // return RedirectToAction("BorrowInfoes", new {id=readId });
        }
Esempio n. 9
0
        //查询单个图书借阅信息
        public void GetBorrowInfo()
        {
            string     useGuid    = GetString("useGuid");
            BorrowInfo borrowInfo = borrowInfoBLL.GetBorrowInfo(useGuid);

            RenderJson(borrowInfo);
        }
        private void BtnSave_Click(object sender, EventArgs e)
        {
            if (this.detailList.Count == 0)
            {
                return;
            }
            string     borrowId      = DateTime.Now.ToString("yyyyMMddhhmmssfff");
            BorrowInfo objBorrowInfo = new BorrowInfo()
            {
                BorrowId    = borrowId,
                ReaderId    = this.currentReader.ReaderId,
                AdminName_B = Program.currentAdmin.AdminName
            };

            for (int i = 0; i < this.detailList.Count; i++)
            {
                this.detailList[i].BorrowId = objBorrowInfo.BorrowId;
            }
            try
            {
                objBorrowManager.AddBorrowInfo(objBorrowInfo, this.detailList);
                MessageBox.Show("借阅成功", "提示信息");
                ResetForm();
                this.txtReadingCard.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("系统发生异常:" + ex.Message, "异常提示");
            }
        }
Esempio n. 11
0
        //查询所有图书借阅信息
        public void SearchAllBorrowInfo()
        {
            string key       = GetString("key");
            string sortField = GetString("sortField");
            string sortOrder = GetString("sortOrder");//string sortField,string sortOrder

            if (!string.IsNullOrEmpty(key))
            {
                int pageIndex = GetInt("pageIndex");
                int pageSize  = GetInt("pageSize");
                List <BorrowInfo> borrowInfoList = borrowInfoBLL.GetBorrowInfoByKey(key, pageIndex, pageSize, sortField, sortOrder);
                RenderJson(borrowInfoList);
            }
            else
            {
                //分页
                int pageIndex = GetInt("pageIndex");
                int pageSize  = GetInt("pageSize");
                List <BorrowInfo> borrowList    = borrowInfoBLL.GetList(pageIndex, pageSize, sortField, sortOrder);
                List <BorrowInfo> borroInfoList = new List <BorrowInfo>();
                foreach (var item in borrowList)
                {
                    BorrowInfo borrow = new BorrowInfo();
                    borrow          = item;
                    borrow.BookName = borrow.BookName.Substring(borrow.BookName.LastIndexOf('-') + 1);
                    borroInfoList.Add(borrow);
                }
                int       total  = borrowInfoBLL.GetBorrowInfoCount();
                Hashtable result = new Hashtable();
                result["data"]  = borroInfoList;
                result["total"] = total;
                RenderJson(result);
            }
        }
Esempio n. 12
0
        //根据图书条码查询图书信息
        //读者借书
        public bool AddBorrowInfo(BorrowInfo objBorrowInfo, List <BorrowDetail> detailList)
        {
            //主表实现
            string sqlMain = "insert into BorrowInfo(BorrowId, ReaderId, BorrowDate, AdminName_B)values(@BorrowId, @ReaderId, @BorrowDate, @AdminName_B) ";

            SqlParameter[] param = new SqlParameter[] {
                new SqlParameter("@BorrowId", objBorrowInfo.BorrowId),
                new SqlParameter("@ReaderId", objBorrowInfo.ReaderId),
                new SqlParameter("@BorrowDate", objBorrowInfo.BorrowDate),
                new SqlParameter("@AdminName_B", objBorrowInfo.AdminName_B)
            };
            //副表实现
            string sqlDetail = "insert into BorrowDetail(BorrowId, BookId, BorrowCount, NonReturnCount, Expire)values(@BorrowId, @BookId, @BorrowCount, @NonReturnCount, @Expire)";
            List <SqlParameter[]> paramList = new List <SqlParameter[]>();

            SqlParameter[] paramt = null;
            foreach (BorrowDetail item in detailList)
            {
                paramt = new SqlParameter[] {
                    new SqlParameter("@BorrowId", item.BorrowId),
                    new SqlParameter("@BookId", item.BookId),
                    new SqlParameter("@BorrowCount", item.BorrowCount),
                    new SqlParameter("@NonReturnCount", item.NonReturnCount),
                    new SqlParameter("@Expire", item.Expire)
                };
                paramList.Add(paramt);
            }
            //添加借书
            return(SQLHelper.UpdateByTran(sqlMain, param, sqlDetail, paramList));
        }
Esempio n. 13
0
 public WinLogic()
 {
     book   = new BookInfo();
     borrow = new BorrowInfo();
     user   = new User();
     admin  = new Admin();
     lx     = new LXUser();
 }
        public ActionResult DeleteConfirmed(int id)
        {
            BorrowInfo borrowInfo = db.BorrowInfo.Find(id);

            db.BorrowInfo.Remove(borrowInfo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 15
0
        /// <summary>
        /// 续借
        /// </summary>
        /// <param name="strItemBarcode">册条码号</param>
        /// <returns></returns>
        public int Renew(string strReaderBarcode, string strItemBarcode, out BorrowInfo borrowInfo, out string strError)
        {
            borrowInfo = null;
            strError   = "";

            if (strItemBarcode == null)
            {
                strItemBarcode = "";
            }
            strItemBarcode = strItemBarcode.Trim();
            if (strItemBarcode == "")
            {
                strError = "续借失败:您输入的续借图书编号或者册条码号为空。";
                return(-1);
            }

            if (String.IsNullOrEmpty(strReaderBarcode) == true)
            {
                strError = "续借失败:内部错误,读者证条码号为空。";
                return(-1);
            }

            /*
             * // 优先从序号字典中找下
             * if (this.CurrentMessageContext.BorrowDict.ContainsKey(strItemBarcode))
             * {
             *  string temp = this.CurrentMessageContext.BorrowDict[strItemBarcode];
             *  if (temp != null && temp != "")
             *      strItemBarcode = temp;
             * }
             */

            LibraryChannel channel = this.ChannelPool.GetChannel(this.dp2Url, this.dp2UserName);

            channel.Password = this.dp2Password;
            try
            {
                string strOutputReaderBarcode = "";
                string strReaderXml           = "";
                long   lRet = channel.Borrow(true,
                                             strReaderBarcode,
                                             strItemBarcode,
                                             out strOutputReaderBarcode,
                                             out strReaderXml,
                                             out borrowInfo,
                                             out strError);
                if (lRet == -1)
                {
                    return(-1);
                }

                return(1);
            }
            finally
            {
                this.ChannelPool.ReturnChannel(channel);
            }
        }
Esempio n. 16
0
        //事务
        public bool SaveBorrowInfo(Object obj, string state)
        {
            BorrowInfo borrowInfo = (BorrowInfo)obj;

            try
            {
                if (borrowInfo.UseGuid == null)
                {
                    List <string> strList = GetUseGuidList();
                    if (strList.Count <= 0)
                    {
                        borrowInfo.UseGuid = "JY0001";
                    }
                    else
                    {
                        borrowInfo.UseGuid = GenerateIdentification(GetUseGuidList());
                    }

                    bool r = borrowInfoDal.Inert(borrowInfo);
                    if (r)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (state == null)
                {
                    bool r = borrowInfoDal.Update(borrowInfo);
                    if (r)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    bool r = borrowInfoDal.Delete(borrowInfo.UseGuid);
                    if (r)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 续借
        /// </summary>
        /// <param name="strParam"></param>
        /// <returns></returns>
        private IResponseMessageBase DoRenew(string strParam)
        {
            // 设置当前命令
            this.CurrentMessageContext.CurrentCmdName = dp2CommandUtility.C_Command_Renew;

            long   lRet     = 0;
            string strError = "";

            // 先检查是否绑定读者账号
            lRet = this.CheckIsBinding(out strError);
            if (lRet == -1)
            {
                return(this.CreateTextResponseMessage(strError));
            }
            // 尚未绑定读者账号
            if (lRet == 0)
            {
                return(this.CreateTextResponseMessage("尚未绑定读者账号,请先调binding命令先绑定"));
            }

            // 查看已借图书
            if (strParam == "" || strParam == "view")
            {
                string strBorrowInfo = "";
                lRet = this.CmdService.GetBorrowInfo1(this.CurrentMessageContext.ReaderBarcode, out strBorrowInfo,
                                                      out strError);
                if (lRet == -1 || lRet == 0)
                {
                    return(this.CreateTextResponseMessage(strError));
                }

                // 显示个人信息
                string strMessage = strBorrowInfo + "\n"
                                    + "请输入续借图书编号或者册条码号。";
                return(this.CreateTextResponseMessage(strMessage));
            }


            // 目前只认作册条码,todo支持序号
            BorrowInfo borrowInfo = null;

            lRet = this.CmdService.Renew(this.CurrentMessageContext.ReaderBarcode,
                                         strParam,
                                         out borrowInfo,
                                         out strError);
            if (lRet == -1 || lRet == 0)
            {
                return(this.CreateTextResponseMessage(strError));
            }

            // 显示续借成功信息信息
            string returnTime = DateTimeUtil.ToLocalTime(borrowInfo.LatestReturnTime, "yyyy/MM/dd");
            string strText    = strParam + "续借成功,还书日期为:" + returnTime + "。";

            return(this.CreateTextResponseMessage(strText));
        }
Esempio n. 18
0
 public ArchiveBorrowEntity(BorrowInfo Info)
 {
     this.ID         = Info.ID;
     this.BorrowDept = Info.BorrowDept;
     this.BorrowUser = Info.BorrowUser;
     this.BackDate   = Info.BackDate;
     this.Note       = Info.Note;
     this.BorrowDate = Info.BorrowDate;
     this.Status     = Info.Status;
 }
 public ActionResult Edit([Bind(Include = "borrow_Id,bookName,readerId,borrowTime,backTime,isBeyond")] BorrowInfo borrowInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(borrowInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(borrowInfo));
 }
        public ActionResult Create([Bind(Include = "borrow_Id,bookName,readerId,borrowTime,backTime,isBeyond")] BorrowInfo borrowInfo)
        {
            if (ModelState.IsValid)
            {
                db.BorrowInfo.Add(borrowInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(borrowInfo));
        }
Esempio n. 21
0
        /// <summary>
        /// 续借
        /// </summary>
        /// <param name="strItemBarcode">册条码号</param>
        /// <returns></returns>
        public virtual int Renew(string remoteUserName,
                                 string strReaderBarcode,
                                 string strItemBarcode,
                                 out BorrowInfo borrowInfo,
                                 out string strError)
        {
            borrowInfo = null;
            strError   = "未实现";

            return(-1);
        }
        // GET: BorrowInfoes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BorrowInfo borrowInfo = db.BorrowInfo.Find(id);

            if (borrowInfo == null)
            {
                return(HttpNotFound());
            }
            return(View(borrowInfo));
        }
Esempio n. 23
0
        protected void LoadInformation()
        {
            string        sql = "select top 20 * from tbMeetingRoomUse order by MRUID desc";
            SqlConnection con = new SqlConnection(connStr);
            SqlCommand    cmd = new SqlCommand(sql, con);
            DataSet       ds  = new DataSet();

            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter(sql, con);

            sda.Fill(ds);
            BorrowInfo.DataSource = ds;
            BorrowInfo.DataBind();
            con.Close();
        }
Esempio n. 24
0
        public int returnBook(BorrowInfo borrow, string review)
        {
            sqlDataAccess da = new sqlDataAccess();
            int           val;
            double        review1;
            int           nopr;
            double        temp;
            double        temp2;
            SqlCommand    cmd  = da.GetCommand("Delete BorrowTable  where bookid ='" + borrow.bookId + "'and userid ='" + borrow.userId + "'");
            SqlCommand    cmd1 = da.GetCommand("Select quantity,review,nopr from booktable where bookid ='" + borrow.bookId + "'");

            cmd1.Connection.Open();
            cmd1.ExecuteNonQuery();
            using (SqlDataAdapter dt = new SqlDataAdapter(cmd1))
            {
                DataTable tbl = new DataTable();
                dt.Fill(tbl);
                val     = (int)tbl.Rows[0][0];
                temp2   = (double)tbl.Rows[0][1];
                review1 = (double)temp2;
                nopr    = (int)tbl.Rows[0][2];
                cmd1.Connection.Close();
            }
            if (val >= 0)
            {
                val     = val + 1;
                temp    = Convert.ToDouble(review);
                review1 = review1 + temp;
                nopr   += 1;
                review1 = review1 / (double)nopr;

                SqlCommand cmd2 = da.GetCommand("UPDATE booktable SET  quantity='" + val + "', review='" + review1 + "', nopr='" + nopr + "' where bookid = '" + borrow.bookId + "'");
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                ///////////////////////////////////
                cmd2.Connection.Open();
                cmd2.ExecuteNonQuery();
                cmd2.Connection.Close();
                return(1);
            }
            else
            {
                cmd.Connection.Close();
                return(0);
            }
        }
Esempio n. 25
0
        //根据key查询图书借阅信息
        public List <BorrowInfo> GetBorrowInfoByKey(string key, int pageIndex, int pageSize, string sortField, string sortOrder)
        {
            string sql = null;

            if (string.IsNullOrEmpty(sortField))
            {
                sql = selectSql + "\nwhere bookname like '%" + key + "%'" +
                      " order by useguid offset(@pageIndex)*@pageSize rows fetch next 10 rows only";
            }
            else if (!string.IsNullOrEmpty(sortField) && string.IsNullOrEmpty(sortOrder))
            {
                sql = selectSql + "\nwhere bookname like '%" + key + "%'" +
                      " order by " + sortField + " offset(@pageIndex)*@pageSize rows fetch next 10 rows only";
            }
            else if (!string.IsNullOrEmpty(sortField) && !string.IsNullOrEmpty(sortOrder))
            {
                sql = selectSql + "\nwhere bookname like '%" + key + "%'" +
                      " order by " + sortField + " " + sortOrder + " offset(@pageIndex)*@pageSize rows fetch next 10 rows only";
            }
            List <BorrowInfo> borrowInfoList = new List <BorrowInfo>();

            SqlParameter[] pms = new SqlParameter[]
            {
                new SqlParameter("@pageIndex", pageIndex),
                new SqlParameter("@pageSize", pageSize)
            };
            SqlDataReader reader = SqlHelper.ExecuteReader(sql, CommandType.Text, pms);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    BorrowInfo borrowInfo = new BorrowInfo();
                    borrowInfo.BookName     = reader.GetString(0);
                    borrowInfo.UseGuid      = reader.GetString(1);
                    borrowInfo.BorrowPerson = reader.GetString(2);
                    borrowInfo.Handler      = reader.GetString(3);
                    borrowInfo.BorrowCause  = reader.GetString(4);
                    borrowInfo.BorrowDate   = reader.GetDateTime(5);
                    borrowInfo.ReturnDate   = reader.GetDateTime(6);
                    borrowInfo.Remark       = reader.GetString(7);
                    borrowInfoList.Add(borrowInfo);
                }
            }
            reader.Close();
            return(borrowInfoList);
        }
Esempio n. 26
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //数据验证

            //封装对象【主表】
            BorrowInfo main = new BorrowInfo()
            {
                ReaderId    = this.objReader.ReaderId,
                BorrowId    = DateTime.Now.ToString("yyyyMMddhhmmssms"),
                AdminName_B = Program.admin.AdminName,
            };

            //封装明细对象(将当前明细对象未封装的属性)
            for (int i = 0; i < detailList.Count; i++)
            {
                detailList[i].BorrowId       = main.BorrowId;
                detailList[i].Expire         = DateTime.Now.AddDays(objReader.AllowDay);
                detailList[i].NonReturnCount = detailList[i].BorrowCount;
            }

            try
            {
                borrowService.BorrowBook(main, detailList);//将封装的对象传递对象给业务逻辑完成数据保存
                //各种数据复位
                this.txtBarCode.Clear();
                this.txtBarCode.Enabled = false;
                this.btnDel.Enabled     = false;
                this.btnSave.Enabled    = false;
                this.txtReadingCard.Clear();
                this.lblReaderName.Text  = "";
                this.lblRoleName.Text    = "";
                this.lblAllowCounts.Text = "0";
                this.lbl_Remainder.Text  = "0";
                this.lblBorrowCount.Text = "0";
                dgvBookList.DataSource   = null;
                this.objReader           = null;
                MessageBox.Show("借书成功", "借书提示");
                this.txtReadingCard.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "借书提示");
                throw;
            }
        }
Esempio n. 27
0
        //借书
        //1.有没有这本书
        //2.该书未被借出
        //3.借阅,添加一条借书记录
        private void btnBorrow0_Click(object sender, EventArgs e)
        {
            var bookID = txtBookID0.Text.Trim();

            //判断用户输入图书ID是否正确
            if (string.IsNullOrEmpty(bookID))
            {
                MessageBox.Show("请先输入图书编号!", "温馨提示");
                return;
            }
            if (string.IsNullOrEmpty(userID))
            {
                MessageBox.Show("请先输入借书证号!", "温馨提示");
                return;
            }

            var result = new BorrowInfo().BorrowBook(bookID, userID);

            switch (result)
            {
            case 1:
                MessageBox.Show("借书成功!", "温馨提示");
                //刷新借书记录
                //dgvBorrowInfo0.DataSource = new BorrowInfo().GetBorrowInfoByUserID(userID).Tables[0];
                Paging0(new BorrowInfo().GetBorrowInfoByUserID(userID).Tables[0]);
                LoadPage0();
                break;

            case 9:
                MessageBox.Show("数据访问失败,请重试!", "温馨提示");
                break;

            case -1:
                MessageBox.Show("您输入的图书不存在,请核对!", "温馨提示");
                break;

            case 0:
                MessageBox.Show("此书已经借出,不能重复借书!", "温馨提示");
                break;

            default:
                return;
            }
        }
Esempio n. 28
0
        //借书
        public int BookBrrow(int bookId, int userId)
        {
            CheckDeferBook(userId);
            var bookInfo = bookServer.GetBookModel(bookId);

            var borrowInfo = new BorrowInfo()
            {
                UserId       = userId,
                BookId       = bookId,
                Bo_TypeId    = 1,
                B_MechanId   = bookInfo.MechanId,
                B_StartTime  = DateTime.Now,
                B_EndTime    = DateTime.Now.AddMonths(1),
                B_ReturnTime = Convert.ToDateTime("1900/1/1 00:00:00"),
            };


            if (bookInfo != null && bookInfo.B_StatuId != 2)
            {
                bookInfo.B_StatuId = 2;

                int    result = bookServer.Update(bookInfo);
                int    a      = borrowServer.Insert(borrowInfo);
                Notice notice = new Notice()
                {
                    NoticeTime    = DateTime.Now,
                    N_TypeId      = 2,
                    NoticeTitle   = "借阅成功提醒",
                    NoticeContent = "恭喜您成功借阅《" + bookInfo.BookName + "》,请在一个月之内归还!",
                    UserId        = userId,
                    LibId         = 1001
                };

                noticeServer.Insert(notice);
                return(a == result ? 1 : 0);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 29
0
        /// <summary>
        /// 保存借阅信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSave_Click(object sender, EventArgs e)
        {
            //创建对象
            BorrowInfo borrowInfo = new BorrowInfo
            {
                BorrowId    = CreateBorrowId(),
                ReaderId    = reader.ReaderId,
                AdminName_B = Program.CurrentAdmin.AdminId.ToString()
            };

            for (int i = 0; i < borrowList.Count; i++)
            {
                borrowList[i].BorrowId       = borrowInfo.BorrowId;
                borrowList[i].NonReturnCount = borrowList[i].BorrowCount;
            }
            try
            {
                borrowManager.BorrowBookConfirm(borrowInfo, borrowList);
                MessageBox.Show("借阅成功!", "异常提示");
                //数据复位:
                this.txtBarCode.Clear();
                this.txtBarCode.Enabled     = false;
                this.dgvBookList.DataSource = null;
                this.borrowList             = null;
                this.btnSave.Enabled        = false;
                this.btnDel.Enabled         = false;
                this.lblBorrowCount.Text    = "";
                this.lbl_Remainder.Text     = "";
                this.txtReadingCard.Text    = "";
                this.lblRoleName.Text       = "";
                this.lblReaderName.Text     = "";
                this.lblAllowCounts.Text    = "";
                this.pbReaderImage.Image    = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("借书异常:" + ex.Message, "异常提示");
            }
        }
Esempio n. 30
0
        public async Task <ActionResult> BorrowBook([FromBody] BorrowRequest borrowRequest)
        {
            var currentPerson = personService.GetPersonJwtUsername();

            var book = await bookService.FindBookById(borrowRequest.BookId);

            var person = await personService.FindPersonByUsername(currentPerson);

            if (book is null || !book.IsAvailable)
            {
                return(BadRequest(new ErrorResponse(ErrorTypes.NotFound.EnumDescription())));
            }

            var borrow = new BorrowInfo(person, book);
            await personService.BorrowBook(borrow);

            await bookService.UpdateBookOwner(book, person);

            var borrowMapper = mapper.Map <BorrowResponse>(borrow);

            return(Ok(borrowMapper));
        }
Esempio n. 31
0
        public BorrowInfo AddBorrowInfo(BorrowInfo _borrow)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    context.BorrowInfoes.Add(_borrow);

                    context.SaveChanges();
                    return _borrow;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
Esempio n. 32
0
        // 借阅动作异步事件
        internal void BorrowAsync(IChargingForm charging_form,
            bool bRenew,
            string strReaderBarcode,
            string strItemBarcode,
            string strConfirmItemRecPath,
            string strReaderSummary,
            string strItemXml,
            BorrowInfo borrow_info,
            DateTime start_time,
            DateTime end_time)
        {

#if !USE_THREAD
            Delegate_Borrow d = new Delegate_Borrow(Borrow);
            this.MainForm.BeginInvoke(d, new object[] { charging_form,
            bRenew,
            strReaderBarcode,
            strItemBarcode,
            strConfirmItemRecPath,
            strReaderSummary,
            strItemXml, 
            borrow_info,
            start_time,
            end_time});
#else
            OneCall call = new OneCall();
            call.name = "borrow";
            call.func = new Delegate_Borrow(Borrow);
            call.parameters = new object[] { charging_form,
            bRenew,
            strReaderBarcode,
            strItemBarcode,
            strConfirmItemRecPath,
            strReaderSummary,
            strItemXml, 
            borrow_info,
            start_time,
            end_time};

            AddCall(call);
#endif
        }
Esempio n. 33
0
        internal void Borrow(
            IChargingForm charging_form,
            bool bRenew,
            string strReaderBarcode,
            string strItemBarcode,
            string strConfirmItemRecPath,
            string strReaderSummary,
            string strItemXml,  // 2008/5/9
            BorrowInfo borrow_info,
            DateTime start_time,
            DateTime end_time)
        {
            TimeSpan delta = end_time - start_time; // 未包括GetSummary()的时间

            string strText = "";
            int nRet = 0;

            string strOperName = "借";
            if (bRenew == true)
                strOperName = "续借";

            string strError = "";
            string strSummary = "";
            nRet = this.GetBiblioSummary(strItemBarcode,
                    strConfirmItemRecPath,
                    out strSummary,
                    out strError);
            if (nRet == -1)
                strSummary = "获取书目摘要时出错: " + strError;

            string strOperClass = "even";
            if ((this.m_nCount % 2) == 1)
                strOperClass = "odd";

            string strItemLink = "<a href='javascript:void(0);' onclick=\"window.external.OpenForm('ItemInfoForm', this.innerText, true);\">" + HttpUtility.HtmlEncode(strItemBarcode) + "</a>";
            string strReaderLink = "<a href='javascript:void(0);' onclick=\"window.external.OpenForm('ReaderInfoForm', this.innerText, true);\">" + HttpUtility.HtmlEncode(strReaderBarcode) + "</a>";

            strText = "<div class='item " + strOperClass + " borrow'>"
                + "<div class='time_line'>"
                + " <div class='time'>" + DateTime.Now.ToLongTimeString() + "</div>"
                + " <div class='time_span'>耗时 " + DoubleToString(delta.TotalSeconds) + "秒</div>"
                + " <div class='clear'></div>"
                + "</div>"
                + "<div class='reader_line'>"
                + " <div class='reader_prefix_text'>读者</div>"
                + " <div class='reader_barcode'>" + strReaderLink + "</div>"
                + " <div class='reader_summary'>" + HttpUtility.HtmlEncode(strReaderSummary) + "</div>"
                + " <div class='clear'></div>"
                + "</div>"
                + "<div class='opername_line'>"
                + " <div class='opername'>" + HttpUtility.HtmlEncode(strOperName) + "</div>"
                + " <div class='clear'></div>"
                + "</div>"
                + "<div class='item_line'>"
                + " <div class='item_prefix_text'>册</div>"
                + " <div class='item_barcode'>" + strItemLink + "</div> "
                + " <div class='item_summary'>" + HttpUtility.HtmlEncode(strSummary) + "</div>"
                + " <div class='clear'></div>"
                + "</div>"
                + " <div class='clear'></div>"
                + "</div>";
            /*
            strText = "<div class='" + strOperClass + "'>"
    + "<div class='time_line'><span class='time'>" + DateTime.Now.ToLongTimeString() + "</span> <span class='time_span'>耗时 " + delta.TotalSeconds.ToString() + "秒</span></div>"
    + "<div class='reader_line'><span class='reader_prefix_text'>读者</span> <span class='reader_barcode'>[" + strReaderBarcode + "]</span>"
+ " <span class='reader_summary'>" + strReaderSummary + "<span></div>"
+ "<div class='opername_line'><span class='opername'>" + strOperName + "<span></div>"
+ "<div class='item_line'><span class='item_prefix_text'>册</span> <span class='item_barcode'>[" + strItemBarcode + "]</span> "
+ "<span class='item_summary' id='" + m_nCount.ToString() + "' onreadystatechange='GetOneSummary(\"" + m_nCount.ToString() + "\");'>" + strItemBarcode + "</span></div>"
+ "</div>";
             * */

            AppendHtml(strText);
            m_nCount++;

            // 运行Script代码
            if (this.PrintAssembly != null)
            {
                BorrowedEventArgs e = new BorrowedEventArgs();
                e.OperName = strOperName;
                e.BiblioSummary = strSummary;
                e.ItemBarcode = strItemBarcode;
                e.ReaderBarcode = strReaderBarcode;
                e.TimeSpan = delta;
                e.ReaderSummary = strReaderSummary;
                e.ItemXml = strItemXml;
                e.ChargingForm = charging_form;

                if (borrow_info != null)
                {
                    if (String.IsNullOrEmpty(borrow_info.LatestReturnTime) == true)
                        e.LatestReturnDate = new DateTime(0);
                    else
                        e.LatestReturnDate = DateTimeUtil.FromRfc1123DateTimeString(borrow_info.LatestReturnTime).ToLocalTime();
                    e.Period = borrow_info.Period;
                    e.BorrowCount = borrow_info.BorrowCount;
                    e.BorrowOperator = borrow_info.BorrowOperator;
                }

                this.PrintHostObj.MainForm = this.MainForm;
                this.PrintHostObj.Assembly = this.PrintAssembly;
                try
                {
                    this.PrintHostObj.OnBorrowed(this, e);
                }
                catch (Exception ex)
                {
                    string strErrorInfo = "<br/>单据打印脚本运行时出错: " + HttpUtility.HtmlEncode(ExceptionUtil.GetDebugText(ex));
                    AppendHtml(strErrorInfo);
                }
                /*
                if (nRet == -1)
                {
                    strText = "<br/>单据打印脚本运行时出错: " + HttpUtility.HtmlEncode(strError);
                    AppendHtml(strText);
                }*/
            }

            // 用tips飞出显示读者和册的摘要信息?或者明确显示在条码后面?
            // 读者证和册条码号本身就是锚点?
            // 读者摘要要么做在前端,通过XML发生,要么做在服务器,用固定规则发生。
        }
Esempio n. 34
0
        public BorrowInfo EditBorrowInfo(BorrowInfo _borrow)
        {
            try
            {
                using (var context = new LibrarySystemEntities())
                {
                    BorrowInfo oldborrow = context.BorrowInfoes.FirstOrDefault(c => c.BorrowId == _borrow.BorrowId);
                    if (oldborrow != null)
                    {
                        oldborrow.BorrowDate = _borrow.BorrowDate;
                        oldborrow.ReturnDate = _borrow.ReturnDate;

                        context.SaveChanges();
                        return oldborrow;
                    }
                    return null;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }