其他分享
首页 > 其他分享> > 三层--删除

三层--删除

作者:互联网

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);
            }
        }

 

标签:Delect,删除,--,SqlParameter,int,var,三层,id
来源: https://www.cnblogs.com/Guyunanqi/p/15569169.html