예제 #1
0
        public void TestMethod1()
        {
            DALTeacherTitle dtt = new DALTeacherTitle();
            TeacherTitle    tt  = new TeacherTitle();

            tt.TeacherTitleName        = "AA";
            tt.TeacherTitleDescription = "OK";
            Assert.AreEqual(dtt.AddTeacherTitle(tt), true);
        }
예제 #2
0
        public bool AddTeacherTitle(TeacherTitle teacherTitle)
        {
            string sql = "insert into TeacherTitle(TeacherTitleName, TeacherTitleDescription) values(@TeacherTitleName, @TeacherTitleDescription)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@TeacherTitleName",        SqlDbType.VarChar, 50),
                new SqlParameter("@TeacherTitleDescription", SqlDbType.VarChar, 200)
            };

            parameters[0].Value = teacherTitle.TeacherTitleName;
            parameters[1].Value = teacherTitle.TeacherTitleDescription;

            int n = DBHelper.ExecuteCommand(sql, parameters);

            return(n == 1);
        }
예제 #3
0
        public IList <TeacherTitle> GetAllTeahcerTitle()
        {
            IList <TeacherTitle> listTeacherTitle = new List <TeacherTitle>();
            string sql = "select * from TeacherTitle";

            using (SqlDataReader reader = DBHelper.ExecuteReader(sql))
            {
                while (reader.Read())
                {
                    TeacherTitle teacherTitle = new TeacherTitle();
                    teacherTitle.TeacherTitleId          = int.Parse(reader["TeacherTitleId"].ToString());
                    teacherTitle.TeacherTitleName        = reader["TeacherTitleName"].ToString();
                    teacherTitle.TeacherTitleDescription = reader["TeacherTitleDescription"].ToString();
                    listTeacherTitle.Add(teacherTitle);
                }
            }
            return(listTeacherTitle);
        }