Esempio n. 1
0
        public static int DeleteBorrowedById(int id)
        {
            int iSuccess = 0;
            int uSuccess = 0;

            BorrowORLoanInfo borrowInfo = BorrowDAL.GetBorrowById(id);
            UserInfo         userInfo   = UserDAL.GetUserByName(borrowInfo.Borrower);

            BorrowDAL.DeleteBorrowed(id, out iSuccess);

            if (iSuccess > 0)
            {
                if (borrowInfo.BorrowORLoanType == 2)
                {
                    CardInfo cardInfo     = CardDAL.GetCardByCardNumber(borrowInfo.BorrowedAccount, userInfo.Id);
                    float    amount       = cardInfo.Amount - borrowInfo.Amount;
                    float    borrowAmount = cardInfo.BorrowAmount - borrowInfo.Amount;
                    CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
                }
            }
            if (iSuccess > 0 && ((borrowInfo.BorrowORLoanType == 2 && uSuccess > 0) || (borrowInfo.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 2
0
        private bool ValidBorrow(string email, string bookName, string publishingHouse, int publicationYear)
        {
            Inventory inventory = EditionDAL.GetEditionInventory(bookName, publishingHouse, publicationYear);

            if (inventory.CurrentStock <= 0.1 * inventory.InitialStock)
            {
                Helper.DisplayError("\n There are no books available for borrow.");
                return(false);
            }

            int           NMC     = Helper.GetConfigData()["NMC"];
            int           PER     = Helper.GetConfigData()["PER"];
            List <Borrow> borrows = BorrowDAL.GetBorrowsForUser(email);

            borrows.RemoveAll(d => d.EndDate < DateTime.Today);

            if (borrows.Count >= NMC)
            {
                Borrow firstBorrow = borrows[borrows.Count - NMC];
                Borrow lastBorrow  = borrows[borrows.Count - 1];

                if (DateTime.Today >= lastBorrow.StartDate && DateTime.Today < firstBorrow.StartDate.AddDays(PER * 7))
                {
                    Helper.DisplayError("\n You can't borrow another book. Come again on " + firstBorrow.StartDate.AddDays(PER * 7));
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 3
0
        public static bool run_insql(Borrow br, int i)
        {
            switch (i)
            {
            case 0: return(BorrowDAL.ex_insert_insql(br));

            case 1: return(BorrowDAL.ex_update_insql(br));

            case 2: return(BorrowDAL.ex_delete_insql(br));

            default: return(false);
            }
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            Borrow borrow = new Borrow();

            int flag = Convert.ToInt32(context.Request["flag"]);

            borrow.ID          = Convert.ToInt32(context.Request["ID"]);
            borrow.UID         = Convert.ToInt32(context.Request["UID"]);
            borrow.BID         = Convert.ToInt32(context.Request["BID"]);
            borrow.Borrow_time = Convert.ToDateTime(context.Request["Borrow_time"]);
            borrow.Return_time = Convert.ToDateTime(context.Request["Return_time"]);
            borrow.Is_return   = context.Request["Is_return"];

            if (flag == 0)
            {
                DataTable GetBorrow = BorrowDAL.GetBorrow();
                string    json      = null;
                if (GetBorrow != null)
                {
                    json = Common.JsonHelper.DataSetToJson(GetBorrow);
                }
                context.Response.Write(json);
            }
            else if (flag == 1)
            {
                DataTable GetBorrow = BorrowDAL.Select(borrow.UID);
                string    json      = null;
                if (GetBorrow != null)
                {
                    json = Common.JsonHelper.DataSetToJson(GetBorrow);
                }
                context.Response.Write(json);
            }
            else if (flag == 2)
            {
                int Insert = BorrowDAL.Insert(borrow);
                context.Response.Write(Insert);
            }
            else if (flag == 3)
            {
                int Update = BorrowDAL.Update(borrow);
                context.Response.Write(Update);
            }
            else if (flag == 4)
            {
                int Delete = BorrowDAL.Delete(borrow);
                context.Response.Write(Delete);
            }
        }
Esempio n. 5
0
        public List <Borrow> GetBorrowsForUser()
        {
            string email = Helper.ReadString("Introduce the email of the user:"******"\n Wrong email!");
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                email = Helper.ReadString("Reintroduce the email of the user:");
            }

            List <Borrow> borrows = null;

            borrows = BorrowDAL.GetBorrowsForUser(email);
            return(borrows);
        }
Esempio n. 6
0
        public static int InsertOrUpdatetoBorrowed(BorrowORLoanInfo info)
        {
            int iSuccess = 0;
            int uSuccess = 0;
            BorrowORLoanInfo borrowInfo = new BorrowORLoanInfo();
            UserInfo         userInfo   = UserDAL.GetUserByName(info.Borrower);
            CardInfo         cardInfo   = CardDAL.GetCardByCardNumber(info.BorrowedAccount, userInfo.Id);

            if (info.Id > 0)
            {
                borrowInfo = BorrowDAL.GetBorrowById(info.Id);
            }
            BorrowDAL.InsertOrUpdatetoBorrowed(info, out iSuccess);
            if (iSuccess > 0 && info.BorrowORLoanType == 2)
            {
                float amount       = 0;
                float borrowAmount = 0;
                if (info.Id > 0)
                {
                    amount       = cardInfo.Amount + (info.Amount - borrowInfo.Amount);
                    borrowAmount = cardInfo.BorrowAmount + (info.Amount - borrowInfo.Amount);
                }
                else
                {
                    amount       = cardInfo.Amount + info.Amount;
                    borrowAmount = cardInfo.BorrowAmount + info.Amount;
                }
                CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
            }

            if ((iSuccess > 0 && info.Id > 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(2);
            }
            else if ((iSuccess > 0 && info.Id == 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 7
0
 //显示所借书信息
 public DataTable GetBorrow(int rdID)
 {
     return(BorrowDAL.GetBorrow(rdID));
 }
Esempio n. 8
0
 //按书名查找
 public DataTable GetBookName(string bkName)
 {
     return(BorrowDAL.GetBookName(bkName));
 }
Esempio n. 9
0
 //借书
 public int Insert(Borrow borrow)
 {
     return(BorrowDAL.Insert(borrow));
 }
Esempio n. 10
0
        public bool delByStaffName(string StaffName, string PhoneID)
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.delByStaffName(StaffName, PhoneID));
        }
Esempio n. 11
0
 //按序号查找
 public DataTable GetBookID(int bkID)
 {
     return(BorrowDAL.GetBookID(bkID));
 }
Esempio n. 12
0
 //续借时更新borrow表记录
 public int UpdateContinue(Borrow borrow)
 {
     return(BorrowDAL.UpdateContinue(borrow));
 }
Esempio n. 13
0
 //根据读者类别rdTye获取可借书天数等信息
 public DataTable GetReaderType(int rdType)
 {
     return(BorrowDAL.GetReaderType(rdType));
 }
Esempio n. 14
0
        public static void ConnectDataBase()
        {
            #region DAL.ReaderType测试
            Console.WriteLine("DAL.SqlHelper:测试数据库连接...");
            SqlHelper.OpenConn();

            Console.WriteLine("DAL.SqlHelper:测试数据库关闭...\n");
            SqlHelper.CloseConn();

            Console.WriteLine("Model.ReaderType:测试创建数据单元...");
            ReaderType rdt1 = new ReaderType();
            rdt1.rdType           = 1;
            rdt1.rdTypeName       = "admin";
            rdt1.maxBorrowDay     = 30;
            rdt1.maxBorrowNum     = 8;
            rdt1.maxContinueTimes = 1;

            Console.WriteLine("DAL.ReaderType:测试Delete()...");
            ReaderTypeDAL.Delete(rdt1);

            Console.WriteLine("DAL.ReaderType:测试Add()...");
            rdt1.rdType = ReaderTypeDAL.Add(rdt1);

            string old_rdTypeName = rdt1.rdTypeName;
            rdt1.rdTypeName = "管理员";
            Console.WriteLine("DAL.ReaderType:测试Update()...rdType由" + old_rdTypeName + "改为" + rdt1.rdTypeName + "\n");
            ReaderTypeDAL.Update(rdt1);
            #endregion

            #region DAL.Reader测试
            Console.WriteLine("Model.Reader:测试创建数据单元...");
            Reader rd1 = new Reader();
            rd1.rdID            = 1;
            rd1.rdUsername      = "******";
            rd1.rdPassword      = "******";
            rd1.rdName          = "duguying";
            rd1.rdSex           = "男";
            rd1.rdType          = 1;
            rd1.rdDept          = "计科院";
            rd1.rdPhone         = "18900000000";
            rd1.rdEmail         = "*****@*****.**";
            rd1.rdDateReg       = DateTime.Now;
            rd1.rdPhoto         = Encoding.Default.GetBytes("test");
            rd1.rdStatus        = "正常";
            rd1.rdHaveBorrowNum = 1;

            Console.WriteLine("DAL.Reader:测试Delete()...");
            ReaderDAL.Delete(rd1);

            Console.WriteLine("DAL.Reader:测试Add()...");
            rd1.rdID = ReaderDAL.Add(rd1);

            string old_rdPassword = rd1.rdPassword;
            rd1.rdPassword = "******";
            Console.WriteLine("DAL.Reader:测试Update()...rdPassword由" + old_rdPassword + "改为" + rd1.rdPassword + "\n");
            ReaderDAL.Update(rd1);
            #endregion

            #region DAL.Borrow测试
            Console.WriteLine("Model.Borrow:测试创建数据单元...");
            Borrow br1 = new Borrow();
            br1.borrowId        = 1;
            br1.bkId            = 1;
            br1.ldContinueTimes = 0;
            br1.ldDateOut       = DateTime.Now;
            br1.ldDateRetPlan   = DateTime.Now;
            br1.ldDateRetAct    = DateTime.Now;
            br1.ldOverDay       = 12;
            br1.ldOverMoney     = 1.2f;
            br1.IsHasReturn     = false;
            br1.OperatorLendId  = 1;
            br1.OperatorRetId   = 0;

            Console.WriteLine("DAL.Borrow:测试Delete()...");
            BorrowDAL.Delete(br1);

            Console.WriteLine("DAL.Borrow:测试Add()...");
            br1.borrowId = (decimal)BorrowDAL.Add(br1);

            float old_ldPunishMoney = br1.ldPunishMoney;
            br1.ldPunishMoney = 2.4f;
            Console.WriteLine("DAL.Borrow:测试Update()...ldPunishMoney由" + old_ldPunishMoney + "改为" + br1.ldPunishMoney + "\n");
            BorrowDAL.Update(br1);
            #endregion

            #region DAL.Book测试
            Console.WriteLine("Model.Book:测试创建数据单元...");
            Book bk1 = new Book();
            bk1.bkId        = 1;
            bk1.bkCode      = "1234";
            bk1.bkName      = "测试书籍";
            bk1.bkAuthor    = "作者";
            bk1.bkPress     = "出版社";
            bk1.bkDatePress = DateTime.Now;
            bk1.bkISBN      = "92520111234";
            bk1.bkCatalog   = "计算机科学";
            bk1.bkLanguage  = 0;
            bk1.bkPages     = 300;
            bk1.bkPrice     = 30.5f;
            bk1.bkDateIn    = DateTime.Now;
            bk1.bkBrief     = "Go语言基础教程";
            bk1.bkCover     = Encoding.Default.GetBytes("test");
            bk1.bkStatus    = "在馆";

            Console.WriteLine("DAL.Book:测试Delete()...");
            BookDAL.Delete(bk1);

            Console.WriteLine("DAL.Book:测试Add()...");
            bk1.bkId = BookDAL.Add(bk1);

            string old_bkName = bk1.bkName;
            bk1.bkName = "Go语言云动力";
            Console.WriteLine("DAL.Book:测试Update()...bkName由" + old_bkName + "改为" + bk1.bkName + "\n");
            BookDAL.Update(bk1);
            #endregion

            #region DAL.Admin测试
            Console.WriteLine("Model.Admin:测试创建数据单元...");
            Admin ad1 = new Admin();
            ad1.adminId            = 1;
            ad1.adminUsername      = "******";
            ad1.adminPassword      = "******";
            ad1.adminEmail         = "*****@*****.**";
            ad1.adminLastLoginDate = DateTime.Now;

            Console.WriteLine("DAL.Admin:测试Delete()...");
            AdminDAL.Delete(ad1);

            Console.WriteLine("DAL.Admin:测试Add()...");
            ad1.adminId = AdminDAL.Add(ad1);

            string old_adminPassword = ad1.adminPassword;
            ad1.adminPassword = "******";
            Console.WriteLine("DAL.Admin:测试Update()...adminPassword由" + old_adminPassword + "改为" + ad1.adminPassword + "\n");
            AdminDAL.Update(ad1);
            #endregion

            #region 测试数据清理
            ReaderTypeDAL.Delete(rdt1);
            Console.WriteLine("ReaderType:数据已清理");
            ReaderDAL.Delete(rd1);
            Console.WriteLine("Reader:数据已清理");
            BorrowDAL.Delete(br1);
            Console.WriteLine("Borrow:数据已清理");
            BookDAL.Delete(bk1);
            Console.WriteLine("Book:数据已清理");
            AdminDAL.Delete(ad1);
            Console.WriteLine("Admin:数据已清理\n");
            #endregion

            #region DAL.Admin扩展操作测试
            AdminDAL.getAdminByUsername("lijun");
            #endregion
        }
Esempio n. 15
0
 //根据Book表查询图书状态
 public DataTable GetbkStatus(int bkID)
 {
     return(BorrowDAL.GetbkStatus(bkID));
 }
Esempio n. 16
0
 public static Int32 GetBorrowNotReturn(Reader reader)
 {
     return(BorrowDAL.Counter(reader.rdID));
 }
Esempio n. 17
0
        public static Int32 SubmitAction(UserAction action)
        {
            switch (action.actionSource)
            {
            case "ReaderType":
                switch (action.actionType)
                {
                case "Add":
                    try
                    {
                        return(ReaderTypeDAL.Add((ReaderType)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Update":
                    try
                    {
                        return(ReaderTypeDAL.Update((ReaderType)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Delete":
                    try
                    {
                        return(ReaderTypeDAL.Delete((ReaderType)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                default:
                    throw new Exception("Error actionType!");
                }

            case "Reader":
                switch (action.actionType)
                {
                case "Add":
                    try
                    {
                        return(ReaderDAL.Add((Reader)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Update":
                    try
                    {
                        return(ReaderDAL.Update((Reader)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Delete":
                    try
                    {
                        return(ReaderDAL.Delete((Reader)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Password":
                    try
                    {
                        return(ReaderDAL.Password((Reader)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Permission":
                    try
                    {
                        return(ReaderDAL.Permission((Reader)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                default:
                    throw new Exception("Error actionType!");
                }

            case "Book":
                switch (action.actionType)
                {
                case "Add":
                    try
                    {
                        return(BookDAL.Add((Book)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Update":
                    try
                    {
                        return(BookDAL.Update((Book)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Delete":
                    try
                    {
                        return(BookDAL.Delete((Book)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                default:
                    throw new Exception("Error actionType!");
                }

            case "Borrow":
                switch (action.actionType)
                {
                case "Borrow":
                    try
                    {
                        return(BorrowDAL.Borrow((Borrow)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Update":
                    try
                    {
                        return(BorrowDAL.Update((Borrow)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Delete":
                    try
                    {
                        return(BorrowDAL.Delete((Borrow)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Return":
                    try
                    {
                        return(BorrowDAL.Return((Borrow)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                case "Continue":
                    try
                    {
                        return(BorrowDAL.Continue((Borrow)action.actionModel));
                    }
                    catch (Exception)
                    {
                        return(0);
                    }

                default:
                    throw new Exception("Error actionType!");
                }

            default:
                throw (new Exception("Error actionSource!"));
            }
        }
Esempio n. 18
0
        public bool returnPhone(string StaffName, string PhoneName, string PhoneStage, string PhoneNum, string Test, string IsNormal, string Remark)
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.returnPhone(StaffName, PhoneName, PhoneStage, PhoneNum, Test, IsNormal, Remark));
        }
Esempio n. 19
0
        public bool isBorrowed(string PhoneID)
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.isBorrowed(PhoneID));
        }
Esempio n. 20
0
        public IList <BorrowInfo> selByCondition(string strSql)
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.selByCondition(strSql));
        }
Esempio n. 21
0
 //获取读者信息
 public DataTable GetReader(int rdID)
 {
     return(BorrowDAL.GetReader(rdID));
 }
Esempio n. 22
0
 public static BorrowORLoanCollection GetBorrowList(List <QueryElement> list)
 {
     return(BorrowDAL.GetBorrowList(list));
 }
Esempio n. 23
0
 //借书后更新读者借书本数
 public int UpdateBorrowNum(Reader reader)
 {
     return(BorrowDAL.UpdateBorrowNum(reader));
 }
Esempio n. 24
0
        public IList <BorrowInfo> GetNoneBorrow()
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.getNoneBorrow());
        }
Esempio n. 25
0
 //还书时更新所借图书信息
 public int UpdateBk(Borrow borrow)
 {
     return(BorrowDAL.UpdateBk(borrow));
 }
Esempio n. 26
0
 //dgvBook指定行操作
 public static Borrow GetBookInformation(int bkID)
 {
     return(BorrowDAL.GetObjectByID(bkID));
 }
Esempio n. 27
0
 //根据Reader表查询证件状态
 public DataTable GetrdStatus(int rdID)
 {
     return(BorrowDAL.GetrdStatus(rdID));
 }
Esempio n. 28
0
        public bool addBorrow(string StaffName, string PhoneName, string PhoneStage, string PhoneNum, string Operator)
        {
            BorrowDAL borrowdal = new BorrowDAL();

            return(borrowdal.addBorrow(StaffName, PhoneName, PhoneStage, PhoneNum, Operator));
        }
Esempio n. 29
0
 public static DataTable GetDTby(string type, string content, int row, int number, int rdID)
 {
     return(BorrowDAL.Searchby(type, content, row, number, rdID));
 }
Esempio n. 30
0
 public static BorrowORLoanInfo GetBorrowById(int id)
 {
     return(BorrowDAL.GetBorrowById(id));
 }