Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(AMS_CampusModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_Campus(");
            strSql.Append("Number,SchoolId,Name,Describe)");
            strSql.Append(" values (");
            strSql.Append("@Number,@SchoolId,@Name,@Describe)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",   SqlDbType.NVarChar, 50),
                new SqlParameter("@SchoolId", SqlDbType.Int,       4),
                new SqlParameter("@Name",     SqlDbType.NVarChar, 50),
                new SqlParameter("@Describe", SqlDbType.NVarChar, 200)
            };

            parameters[0].Value = model.Number;
            parameters[1].Value = model.SchoolId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Describe;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS_CampusModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_Campus set ");
            strSql.Append("Number=@Number,");
            strSql.Append("SchoolId=@SchoolId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Describe=@Describe");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Number",   SqlDbType.NVarChar,  50),
                new SqlParameter("@SchoolId", SqlDbType.Int,        4),
                new SqlParameter("@Name",     SqlDbType.NVarChar,  50),
                new SqlParameter("@Describe", SqlDbType.NVarChar, 200),
                new SqlParameter("@Id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Number;
            parameters[1].Value = model.SchoolId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Describe;
            parameters[4].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 更新校区
 /// </summary>
 public bool UpdateCampus()
 {
     try
     {
         AMS_CampusModel samecampus = AMS_CampusBLL.GetCampusInfoByNum(_Number);
         if (samecampus == null || samecampus.Id == _Id)
         {
             AMS_CampusModel newcampus = new AMS_CampusModel();
             newcampus.Describe = _Describe;
             newcampus.Id       = _Id;
             newcampus.Name     = _Name;
             newcampus.Number   = _Number;
             newcampus.SchoolId = _Schoolid;
             if (AMS_CampusBLL.UpdateCampus(newcampus) == AdvertManage.Model.Enum.HandleResult.Failed)
             {
                 throw new Exception("修改校区失败,具体详情请查看日志文件!");
             }
             return(true);
         }
         else
         {
             throw new Exception("已有重复的校区编号!");
         }
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message);
         return(false);
     }
 }