示例#1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            GoodsTypeDataContext lq = new GoodsTypeDataContext(); //实例化LINQ类
            GoodsType            gt = new GoodsType();            //创建一个新对象

            gt.tName = TextBox1.Text;
            lq.GoodsType.InsertOnSubmit(gt); //执行插入数据操作
            lq.SubmitChanges();              //提交数据库
            LoadData();
        }
示例#2
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            GoodsTypeDataContext lq = new GoodsTypeDataContext();       //实例化LINQ类
            var types = from gt in lq.GoodsType
                        where gt.tName == TextBox4.Text
                        select gt;

            foreach (GoodsType type in types)
            {
                lq.GoodsType.DeleteOnSubmit(type);
            }
            lq.SubmitChanges();
            LoadData();
        }
示例#3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            GoodsTypeDataContext lq = new GoodsTypeDataContext();       //实例化LINQ类
            var types = from gt in lq.GoodsType
                        where gt.tName == TextBox2.Text
                        select gt;

            foreach (var type in types)              //遍历集合
            {
                type.tName = TextBox3.Text;
            }
            lq.SubmitChanges();
            LoadData();
        }