Пример #1
0
        public bool Update(Model.TeacherAccount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [teacher_account] set ");
            strSql.Append("password=@Password");
            strSql.Append(" where teacherno=@TeacherNo ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Password",  SqlDbType.VarChar, 50),
                new SqlParameter("@TeacherNo", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.Password;
            parameters[1].Value = model.TeacherNo;
            int rows = SqlDbHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);

            if (rows == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public bool Add(Model.TeacherAccount model)
        {
            string strSql = "insert into teacher_account values(@TeacherNo,@Password)";

            SqlParameter[] parameters =
            {
                new SqlParameter("@TeacherNo", SqlDbType.VarChar, 50),
                new SqlParameter("@Password",  SqlDbType.VarChar, 50),
            };
            parameters[0].Value = model.TeacherNo;
            parameters[1].Value = model.Password;
            int n = SqlDbHelper.ExecuteNonQuery(strSql, CommandType.Text, parameters);

            if (n == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public bool Login(Model.TeacherAccount model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(1) from [teacher_account]");
            strSql.Append(" where teacherno=@TeacherNo and password=@Password");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TeacherNo", SqlDbType.VarChar, 50),
                new SqlParameter("@Password",  SqlDbType.VarChar, 50),
            };
            parameters[0].Value = model.TeacherNo;
            parameters[1].Value = model.Password;
            int n = Convert.ToInt32(SqlDbHelper.ExecuteScalar(strSql.ToString(), CommandType.Text, parameters));

            if (n == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }