示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DiDaJiangCheng.Model.tbSpecialtyInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tbSpecialtyInfo(");
            strSql.Append("SpecialtyName,SpecialtyDescription");
            strSql.Append(") values (");
            strSql.Append("@SpecialtyName,@SpecialtyDescription");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SpecialtyName",        SqlDbType.NVarChar, 50),
                new SqlParameter("@SpecialtyDescription", SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.SpecialtyName;
            parameters[1].Value = model.SpecialtyDescription;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DiDaJiangCheng.Model.tbSpecialtyInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tbSpecialtyInfo set ");

            strSql.Append(" SpecialtyName = @SpecialtyName , ");
            strSql.Append(" SpecialtyDescription = @SpecialtyDescription  ");
            strSql.Append(" where SpecialtyId=@SpecialtyId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@SpecialtyId",          SqlDbType.Int,       4),
                new SqlParameter("@SpecialtyName",        SqlDbType.NVarChar, 50),
                new SqlParameter("@SpecialtyDescription", SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.SpecialtyId;
            parameters[1].Value = model.SpecialtyName;
            parameters[2].Value = model.SpecialtyDescription;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DiDaJiangCheng.Model.tbSpecialtyInfo GetModel(int SpecialtyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select SpecialtyId, SpecialtyName, SpecialtyDescription  ");
            strSql.Append("  from tbSpecialtyInfo ");
            strSql.Append(" where SpecialtyId=@SpecialtyId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SpecialtyId", SqlDbType.Int, 4)
            };
            parameters[0].Value = SpecialtyId;


            DiDaJiangCheng.Model.tbSpecialtyInfo model = new DiDaJiangCheng.Model.tbSpecialtyInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["SpecialtyId"].ToString() != "")
                {
                    model.SpecialtyId = int.Parse(ds.Tables[0].Rows[0]["SpecialtyId"].ToString());
                }
                model.SpecialtyName        = ds.Tables[0].Rows[0]["SpecialtyName"].ToString();
                model.SpecialtyDescription = ds.Tables[0].Rows[0]["SpecialtyDescription"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }