public BorrowResult(Model.Viewer _viewer, Model.Book _book, Model.Manager _manager)
 {
     InitializeComponent();
     viewer = _viewer;
     book = _book;
     manager = _manager;
     RenderData(viewer, book, manager);
 }
示例#2
0
        public void BorrowVIdErrTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "book";
            viewer.Id = "s000001";//学号错误
            manager.Id = "manager";

            //bool expected = false;    //期望值
            //bool actual;
            int expected = 0;    //期望值
            Hashtable actual;

            SQLDAL.Book target = new SQLDAL.Book();
            actual = target.Borrow(book, viewer, manager); //实际值
            Assert.AreEqual(expected, actual["result"]);
        }
示例#3
0
        public void BorrowTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "book";
            viewer.Id = "st";
            manager.Id = "manager";

              //  bool expected = false;    //期望值//因为数据库中已经存在这一项数据 所以为false
            //bool actual;

            int expected = 0;    //期望值//因为数据库中已经存在这一项数据 所以为false
            Hashtable actual;

            SQLDAL.Book target = new SQLDAL.Book();
            actual = target.Borrow(book, viewer, manager); //实际值
            Assert.AreEqual(expected, actual["result"]);
        }
示例#4
0
        public Model.Viewer GetViewerName(string r_id)
        {
            string strSql = "select r_name from [Viewer] where r_id=@r_id";
            SqlParameter[] parameters ={
                           new SqlParameter ("@r_id",SqlDbType .VarChar,50),
                                      };
            parameters[0].Value = r_id;

            Model.Viewer model = new Model.Viewer();
            DataTable dt = SqlDbHelper.ExecuteDataTable(strSql.ToString(),
                             CommandType.Text, parameters);
            if(dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["r_name"] != null && dt.Rows[0]["r_name"].ToString() != "")
                {
                    model.Name = dt.Rows[0]["r_name"].ToString();
                }
            }
            return model;
        }
示例#5
0
        private void RenderData()
        {
            Model.Viewer viewer = new Model.Viewer();
            string sql = "";
            string [] ColName ;
            //学生
            if(UserHelper.IDENTITY == 0)
            {
                viewer.Id = UserHelper.userId;
                dataGridView1.DataSource = record_bll.GetUserRecord(viewer, sql);
                ColName = new string[]{ "书籍编号", "书籍名称", "书籍作者", "出版社", "借阅日期", "状态" };
            } else
            {
                dataGridView1.DataSource = record_bll.GetAllRecord();
                ColName = new string[] { "书籍编号", "书籍名称", "学生编号","学生名字","书籍作者", "出版社", "借阅日期", "状态" };
            }

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                dataGridView1.Columns[i].HeaderText = ColName[i];
            }
        }
示例#6
0
        public void getRecordBorrowTime()
        {
            string b_id = "9787550264601";
            string r_id = "s001";
            Model.Viewer v = new Model.Viewer();
            v.Id = r_id;
            Model.Book b = new Model.Book();
            b.Id = b_id;

            DateTime expected = new DateTime();    //期望值
            expected = Convert.ToDateTime("2015-12-15");
            DateTime actual;

            SQLDAL.Record target = new SQLDAL.Record();
            actual = target.getRecordBorrowTime(b, v); //实际值
            Assert.AreEqual(expected, actual);
        }
示例#7
0
        public void ReturnVIdErrTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "book";
            viewer.Id = "s00001";//学号错误
            manager.Id = "manager";

            bool expected = false;    //期望值
            bool actual;

            SQLDAL.Book target = new SQLDAL.Book();
            actual = target.ReturnBook(viewer, book, manager); //实际值
            Assert.AreEqual(expected, actual);
        }
示例#8
0
        public void ReturnTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "9787569902921";
            viewer.Id = "s001";
            manager.Id = "manager";

            bool expected = false;    //期望值//因为数据库中已经存在这一项数据 所以为false
            bool actual;

            SQLDAL.Book target = new SQLDAL.Book();
            actual = target.ReturnBook(viewer, book, manager); //实际值
            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public void ReturnBIdErrTest()
        {
            string b_id = "9787550264";
            string r_id = "s001";
            Model.Viewer v = new Model.Viewer();
            v.Id = r_id;
            Model.Book b = new Model.Book();
            b.Id = b_id;
            Model.Manager m = new Model.Manager();
            //m.Id = m_id;
            //Model.Book book = new Model.Book();
            //Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            //book.Id = "boo";//书号错误
            //viewer.Id = "st";
            manager.Id = "manager";

            bool expected = false;    //期望值
            bool actual;

            SQLDAL.Book target = new SQLDAL.Book();
            actual = target.ReturnBook(v, b, manager); //实际值
            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public void MulReturnTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "9787513318525";
            viewer.Id = "st";
            manager.Id = "manager";

            bool expected = false;    //期望值
            bool actual;

            SQLDAL.Book target = new SQLDAL.Book();
            target.ReturnBook(viewer, book, manager); //第一次还
            actual = target.ReturnBook(viewer, book, manager); //实际值//第二次还
            Assert.AreEqual(expected, actual);
        }
示例#11
0
        public void MulBorrowTest()
        {
            Model.Book book = new Model.Book();
            Model.Viewer viewer = new Model.Viewer();
            Model.Manager manager = new Model.Manager();
            book.Id = "9787513318525";
            viewer.Id = "st";
            manager.Id = "manager";

               // bool expected = false;    //期望值
            //bool actual;
            int expected = -1;    //期望值 已经借过的返回值为-1
            Hashtable actual;

            SQLDAL.Book target = new SQLDAL.Book();
            target.Borrow(book, viewer, manager);//第一次借
            actual = target.Borrow(book, viewer, manager); //实际值//第二次借
            Assert.AreEqual(expected, actual["result"]);
            //由于系统限制每个人只能借同一本书一次 所以测试时只有第一次是能成功
        }