コード例 #1
0
 //add test
 public bool DeleteBorrow(Borrow borrow, Client client)
 {
     if (Borrows.Contains(borrow))
     {
         client.Borrowed.Remove(borrow);
         Borrows.Remove(borrow);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        public bool AddBorrow(Client client, Borrow borrow)
        {
            var borrowAdded = borrow;

            if (!Borrows.Contains(borrowAdded))
            {
                Borrows.Add(borrowAdded);
                client.Borrowed.Add(borrowAdded);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public bool AddBorrow(Client client, DateTime dateOfVisit, String description, Decimal price)
        {
            var borrowAdded = new Borrow(client, dateOfVisit, description, price);

            if (!Borrows.Contains(borrowAdded))
            {
                Borrows.Add(borrowAdded);
                client.Borrowed.Add(borrowAdded);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: GZC201314/C-
        private void treeView1_AfterSelect( object sender, TreeViewEventArgs e )
        {
            //            MessageBox.Show(treeView1.SelectedNode.ToString());
            if (treeView1.SelectedNode.ToString().EndsWith("查看违章学生记录"))
            {
                this.Hide();
                View_illstudent stu = new View_illstudent();
                stu.Show();
            }
            else if (treeView1.SelectedNode.ToString().EndsWith("更新数据"))
            {
                this.Hide();
                Update update = new Update();
                update.Show();
            }
            else if (treeView1.SelectedNode.ToString().EndsWith("学生借书"))
            {
                this.Hide();
                Borrow borrow = new Borrow();
                borrow.Show();
            }
            else if (treeView1.SelectedNode.ToString ().EndsWith ( "查看个人信息" ))
            {
                this.Hide ();
                myinformation myinfo = new myinformation();
                myinfo.Show();
            }
            else if (treeView1.SelectedNode.ToString ().EndsWith ( "查看当前借阅" ))
            {
                this.Hide ();
                myborrow mybo = new myborrow();
                mybo.Show();
            }
            else if (treeView1.SelectedNode.ToString ().EndsWith ( "申请续借" ))
            {
                this.Hide ();
                myborrow ba = new myborrow();
                ba.Show();
            }
            else if (treeView1.SelectedNode.ToString ().EndsWith ( "图书查询" ))
            {
                this.Hide ();
                Query query = new Query();
                query.Show();
            }

            //                MessageBox.Show("nicuole");
        }
コード例 #5
0
ファイル: LendBookForm.cs プロジェクト: GuoHM/library
        /// <summary>
        /// Insert a record into borrow table
        /// </summary>
        private void Borrow()
        {
            LibraryEntity context = new LibraryEntity();
            Borrow        bo      = new Borrow();
            Member        me      = context.Member.Where(x => x.NRIC == txtNRIC.Text).First();
            int           bookID  = Convert.ToInt32(txtBookID.Text);
            Books         bok     = context.Books.Where(x => x.BookID == bookID).First();

            bo.Member       = me;
            bo.Books        = bok;
            bo.BookID       = bok.BookID;
            bo.NRIC         = me.NRIC;
            bo.RentalStatus = "out";
            bo.DateIssue    = dtpDOI.Value;
            bo.DateDue      = dtpDueDate.Value;
            bo.Remarks      = txtRemarks.Text;
            context.Borrow.Add(bo);
            context.SaveChanges();
        }
コード例 #6
0
        public IBorrow FindBorrow(params String[] list)
        {
            Borrow item = null;

            foreach (String input in list)
            {
                var itemNext = (Borrow)Borrows.Find(
                    x => x.DateOfBorrow.Equals(DateTime.Parse(input)) ||
                    x.DateOfBorrow.Date == DateTime.Parse(input));
                if (item == null)
                {
                    item = itemNext;
                }
                else
                {
                    return(null);
                }
            }
            return(item);
        }
コード例 #7
0
ファイル: LendBookForm.cs プロジェクト: GuoHM/library
        /// <summary>
        /// Issue borrow book: Insert a borrow record to the borrow table, the total stock of the book minus 1, the quota for member minus 1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnIssuebook_Click(object sender, EventArgs e)
        {
            LibraryEntity context = new LibraryEntity();

            try
            {
                using (TransactionScope transScope = new TransactionScope())
                {
                    int    bookID = Convert.ToInt32(txtBookID.Text);
                    Books  bok    = context.Books.Where(x => x.BookID == bookID).First();
                    Member mem    = context.Member.Where(x => x.NRIC == txtNRIC.Text).First();
                    if (bok.TotalStock > 0 && mem.Quota > 0)
                    {
                        this.Borrow();
                        this.TotalStockminus();
                        this.Quotaminus();
                        toolStripStatusLabel1.Text = "Lend successfully";
                        // Auto increment column, the last record is the newest record
                        int    Count = context.Borrow.Count();
                        Borrow bor   = context.Borrow.ToList()[Count - 1];
                        int    TraID = bor.TransactionID;
                        if (cbPrintReceipt.CheckState == CheckState.Checked)
                        {
                            // The receipt form should given a tranID
                            ReceiptForm rececipt = new ReceiptForm(TraID);
                            rececipt.Show();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please check the totalstock of " + bok.Title + "or the quota of" + mem.MemberName);
                    }
                    transScope.Complete();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please check your NRIC or BookID");
            }
        }
コード例 #8
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (RD.Text != "")
     {
         try
         {
             int i = PR.SelectedIndex;
             op.RequestStatus("Approved", LR[i].Request_Num);
             Borrow tmp = new Borrow(LR[i].ISBN, LR[i].UserName, LR[i].Request_Num, LR[i].DueDate, RD.Text, "Pending");
             op.Userinlist(tmp);
             LR.RemoveAt(i);
             PR.Items.RemoveAt(i);
         }
         catch
         {
             MessageBox.Show("Invalid or No Request to approve");
         }
     }
     else
     {
         MessageBox.Show("To Approve Requests You Must enter The Return Date");
     }
 }
コード例 #9
0
        private void t5btnReturn_Click(object sender, EventArgs e)
        {
            int tkd = 6, tkm = -1;

            //code for tkd

            Student s = new Student();

            s.StudentID = t5txtReturntStudentID.Text;
            DataTable dts = s.search();

            if (dts.Rows.Count == 0)
            {
                MessageBox.Show("چنین دانشجویی نداریم");
            }
            else
            {
                tkd = Convert.ToInt32(dts.Rows[0]["borrowedBookQty"].ToString());
            }

            //code for tkm

            Book b = new Book();

            b.BookCategorizationNo = t5txtReturnCategorizationNo.Text;
            DataTable dtb = b.search();

            if (dtb.Rows.Count == 0)
            {
                MessageBox.Show("چنین کتابی نداریم");
            }
            else
            {
                tkm = Convert.ToInt32(dtb.Rows[0]["bookQty"].ToString());
            }

            if (tkd == 0)
            {
                MessageBox.Show("این دانشجو کتابی در دست امانت ندارد");
            }

            if ((dts.Rows.Count != 0) && (dtb.Rows.Count != 0) && (tkd != 0))
            {
                Borrow borrow = new Borrow();
                borrow.StudentID            = t5txtReturntStudentID.Text;
                borrow.BookCategorizationNo = t5txtReturnCategorizationNo.Text;
                borrow.ReturnDate           = t5txtReturnYear.Text + "/" + t5txtReturnMonth.Text + "/" + t5txtReturnDay.Text;
                borrow.updateBorrow();

                tkm++;
                tkd--;

                s.BorrowedBookQty = Convert.ToString(tkd);
                s.edit_std_amanat();

                b.BookQty = Convert.ToString(tkm);
                b.edit_book_amanat();
            }


            t5txtReturntStudentID.Text       = "";
            t5txtReturnCategorizationNo.Text = "";
            t5txtReturnYear.Text             = "";
            t5txtReturnMonth.Text            = "";
            t5txtReturnDay.Text = "";
        }
コード例 #10
0
        private void t5btnBorrow_Click(object sender, EventArgs e)
        {
            int tkd = 6, tkm = -1;

            //code for tkd

            Student s = new Student();

            s.StudentID = t5txtBorrowtStudentID.Text;
            DataTable dts = s.search();

            if (dts.Rows.Count == 0)
            {
                MessageBox.Show("چنین دانشجویی نداریم");
            }
            else
            {
                tkd = Convert.ToInt32(dts.Rows[0]["borrowedBookQty"].ToString());
            }


            //code for tkm

            Book b = new Book();

            b.BookCategorizationNo = t5txtBorrowCategorizationNo.Text;
            DataTable dtb = b.search();

            if (dtb.Rows.Count == 0)
            {
                MessageBox.Show("چنین کتابی نداریم");
            }
            else
            {
                tkm = Convert.ToInt32(dtb.Rows[0]["bookQty"].ToString());
            }

            if (tkd < 5 && tkm > 0)
            {
                Borrow borrow = new Borrow();
                borrow.StudentID            = t5txtBorrowtStudentID.Text;
                borrow.BookCategorizationNo = t5txtBorrowCategorizationNo.Text;
                borrow.BorrowDate           = t5txtBorrowYear.Text + "/" + t5txtBorrowMonth.Text + "/" + t5txtBorrowDay.Text;
                borrow.insertBorrow();

                tkm--;
                tkd++;

                s.BorrowedBookQty = Convert.ToString(tkd);
                s.edit_std_amanat();


                b.BookQty = Convert.ToString(tkm);
                b.edit_book_amanat();
            }
            else if (tkd == 5)
            {
                MessageBox.Show("دانشجوی گرامی شما حداکثر5 کتاب می توانید به امانت داشته باشید. لطفا یکی از آن ها را بازگردانید");
            }
            else if (tkm == 0)
            {
                MessageBox.Show("کتاب به امانت دیگری است. لطفا رزرو کنید");
            }


            t5txtBorrowtStudentID.Text       = "";
            t5txtBorrowCategorizationNo.Text = "";
            t5txtBorrowYear.Text             = "";
            t5txtBorrowMonth.Text            = "";
            t5txtBorrowDay.Text = "";
        }
コード例 #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            ///提交之前
            if (textBox2.Text == "")
            {
                MessageBox.Show("书籍ID为空!");
                return;
            }
            else if (textBox1.Text == "")
            {
                if (type == 0)//借书时用户不能为空
                {
                    MessageBox.Show("用户ID为空!");
                    return;
                }
            }

            Borrow br = new Borrow();

            br.bkId = int.Parse(textBox2.Text);
            br.rdId = int.Parse(textBox1.Text);

            try {
                if (type == 2)
                {
                    if (BorrowAction.Renew(br) > 0)
                    {
                        MessageBox.Show("续借成功!");
                    }
                    else
                    {
                        MessageBox.Show("续借失败");
                        return;
                    }
                }
                else if (type == 1)
                {
                    if (BorrowAction.Back(br) > 0)
                    {
                        MessageBox.Show("还书成功!");
                    }
                    else
                    {
                        MessageBox.Show("还书失败");
                        return;
                    }
                }
                else
                {
                    if (BorrowAction.Borrow(br) > 0)
                    {
                        MessageBox.Show("借书成功!");
                    }
                    else
                    {
                        MessageBox.Show("借书失败");
                        return;
                    }
                }
            }catch (Exception ex) {
                MessageBox.Show("借书失败!请检查读者ID或书籍ID信息!");
            }

            ///提交之后
            button1.Enabled = false;
        }
コード例 #12
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Borrow borrowWindow = new Borrow();

            borrowWindow.Show();
        }
コード例 #13
0
        public void Userinlist(Borrow BO)
        {
            AdminAddition AA = op.AdminAdd("UTL");

            AA.Add(BO, null, con);
        }