Beispiel #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Department_Model GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,DepartName from Stale_Department ");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Model.Department_Model model = new Model.Department_Model();
            DataTable dt = DbHelperSQL.GetDateSet(strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(dt.Rows[0]["ID"].ToString());
                }
                model.DepartName = dt.Rows[0]["DepartName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Model.Department_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stale_Department set ");
            strSql.Append("DepartName=@DepartName,");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",         SqlDbType.Int,      4),
                new SqlParameter("@DepartName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.DepartName;

            return(DbHelperSQL.ExecuteCommand(strSql.ToString(), parameters));
        }
Beispiel #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Model.Department_Model model)
 {
     return(dals.Update(model));
 }