三层--删除

DAL层

 /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static int Delect(int id)
        {
            var sql = "select * from ClassInfo where id=@id";
            SqlParameter[] sqlParameters = new SqlParameter[]
           {
                new SqlParameter("@id",id)
            };
            return SqlHelper.NonQuery(sql, sqlParameters);
        }

BLL层

 /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static int Delect(int id)
        {
            return ClassInfoDAL.Delect(id);
        }

UI层

 /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDeleting1(object sender, GridViewDeleteEventArgs e)
        {
            var data = e.Keys["Id"];
            var id = Convert.ToInt32(data);
            if (ClassInfoBLL.Delect(id) > 0)
            {
                var url = Request.Url.PathAndQuery;
                Response.Redirect(url);
            }
        }

 

上一篇:通过Eclipse3.1以上启动Tomcat访问不到tomcat管理界面的问题(转载)


下一篇:SQL(DDL、DML、TCL)