Ejemplo n.º 1
0
        /// <summary>
        /// 添加专业类型
        /// </summary>
        /// <param name="specility">专业信息</param>
        public void AddStudentSpecility(StudentSpecility specility)
        {
            try
            {
                string strSql = "insert into usta_StudentSpecility(";
                strSql += "specilityName) ";
                strSql += " values (";
                strSql += "@specilityName)";
                SqlParameter[] parameters = {
                    new SqlParameter("@specilityName", SqlDbType.NVarChar,50)};
                parameters[0].Value = specility.specilityName;

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改学生专业
        /// </summary>
        /// <param name="specility">学生专业</param>
        public void UpdateStudentSpecility(StudentSpecility specility)
        {
            try
            {
                string strSql = "update usta_StudentSpecility set specilityName=@specilityName where specilityId=@specilityId";
                SqlParameter[] parameters = new SqlParameter[2]{
                    new SqlParameter("@specilityId",specility.specilityId),
                    new SqlParameter("@specilityName",specility.specilityName),
                };

                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql, parameters);
            }
            catch (Exception ex)
            {
                MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据专业主键查找
        /// </summary>
        /// <param name="specilityeId">专业主键</param>
        /// <returns>专业信息</returns>
        public StudentSpecility FindStudentSpecilityById(int specilityeId)
        {
            StudentSpecility model = null;
            string commandstring = "select specilityId,specilityName from usta_StudentSpecility where specilityId=@specilityId";
            SqlParameter[] parameters = new SqlParameter[1]{new SqlParameter("@specilityId",specilityeId)
            };

            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, commandstring, parameters);
            if (dr.Read())
            {
                model = new StudentSpecility
                {
                    specilityId = int.Parse(dr["specilityId"].ToString().Trim()),
                    specilityName = dr["specilityName"].ToString().Trim()
                };
            }
            dr.Close();
            conn.Close();
            return model;
        }