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

      

  • 相关阅读:
    es6之class继承
    es6-class基本语法
    vue-cli3搭建pwa项目(一)
    vue 组件的通信方式
    react之组件&props
    React之元素渲染
    JSX
    JSX
    在项目中怎么使用react
    认识react
  • 原文地址:https://www.cnblogs.com/zhuxu/p/5064801.html
Copyright © 2020-2023  润新知