示例#1
0
 /// <summary>
 /// 根据模型中的gid删除指定行
 /// </summary>
 /// <param name="Data"></param>
 /// <returns></returns>
 public int Delete(DAL.UserGoods Data)
 {
     try
     {
         //找到数据上下文中,满足条件的记录
         DAL.UserGoods objT = objDAL.UserGoods.First(x => x.gid == Data.gid);
         //删除该记录
         objDAL.UserGoods.DeleteOnSubmit(objT);
         //更新数据上下文改变到数据库
         objDAL.SubmitChanges();
         return(1);
     }
     catch (Exception)
     {
         return(0);
     }
 }
示例#2
0
        /// <summary>
        /// 根据模型数据,完成表格的插入
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public int Add(DAL.UserGoods Data)
        {
            try
            {
                //向数据上下文数据表中增加一个 模型对象(实体)
                objDAL.UserGoods.InsertOnSubmit(Data);
                //更新数据上下文改变到数据库
                objDAL.SubmitChanges();
                return(1);
            }
            catch (Exception)
            {
                return(0);
            }

            //return objDAL.Add(Data);
        }
示例#3
0
        /// <summary>
        /// 根据uid指定要删除的行,其余字段用于表示要修改的数据值
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public int Update(DAL.UserGoods Data)
        {
            try
            {
                //找到数据上下文中,满足条件的记录
                DAL.UserGoods objT = objDAL.UserGoods.First(x => x.uid == Data.uid && x.gid == Data.gid);
                //修改数据记录
                objT.uid     = Data.uid;
                objT.gid     = Data.gid;
                objT.gtype   = Data.gtype;
                objT.gname   = Data.gname;
                objT.gprice  = Data.gprice;
                objT.gstatus = Data.gstatus;

                //更新数据上下文改变到数据库
                objDAL.SubmitChanges();
                return(1);
            }
            catch (Exception)
            {
                return(0);
            }
        }