zoukankan      html  css  js  c++  java
  • WB 例子 删除

    后台C#代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class Delete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["uid"] != null)
            {
                if (!IsPostBack)
                {
                    testDataContext context = new testDataContext();
                    //取主键值
                    string code = Request["code"].ToString();
                    //查出数据
                    Info data = context.Info.Where(p => p.Code == code).First();
                    //删除
                    //先删除外键表
                    var queryw = context.Work.Where(p => p.InfoCode == code);
                    context.Work.DeleteAllOnSubmit(queryw);
    
                    var queryf = context.Family.Where(p => p.InfoCode == code);
                    context.Family.DeleteAllOnSubmit(queryf);
    
                    //删除自身
                    context.Info.DeleteOnSubmit(data);
    
                    //提交
                    context.SubmitChanges();
                    //返回
                    Response.Redirect("Main.aspx");
    
    
                }
            }
            else
            {
                Response.Redirect("DengLu.aspx");
            }
        }
    }
    

      

  • 相关阅读:
    Android培训准备资料之Android开发环境的搭建
    第二十天
    第十九天
    第十八天
    第十七天
    第十六天
    第十四天
    第十三天
    十二天
    十一天
  • 原文地址:https://www.cnblogs.com/zhuxu/p/5064801.html
Copyright © 2011-2022 走看看