Exemplo n.º 1
0
 public bool DeleteAdvertisement(int systemId, string companyId, string advertisementId)
 {
     try
     {
         int intnum    = 0;
         var dbContext = new DAL.BaseDAL(LdCmsDbEntitiesContext);
         using (var db = dbContext.DbEntities())
         {
             using (var trans = db.Database.BeginTransaction())
             {
                 try
                 {
                     dbContext.Delete <Ld_Extend_Advertisement>(m => m.SystemID == systemId && m.CompanyID == companyId && m.AdvertisementID == advertisementId);
                     dbContext.Delete <Ld_Extend_AdvertisementDetails>(m => m.SystemID == systemId && m.CompanyID == companyId && m.AdvertisementID == advertisementId);
                     intnum = db.SaveChanges();
                     trans.Commit();
                 }
                 catch (Exception)
                 {
                     trans.Rollback();
                 }
                 return(intnum > 0);
             }
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 2
0
        public int DeleteClass(int systemId, string companyId, string classId)
        {
            try
            {
                var expressionPage  = ExtLinq.True <Info_Page>();
                var expressionClass = ExtLinq.True <Info_Class>();

                var expressionPageFindByClassId   = expressionPage.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.ClassID == classId);
                var expressionClassFind           = expressionClass.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.ClassID == classId);
                var expressionClassFindByParentId = expressionClass.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.ParentID == classId);

                if (IsExists(expressionClassFindByParentId))
                {
                    throw new Exception("分类、栏目还有下级栏目不能删除!");
                }
                var entity    = Find(expressionClassFind);
                int classType = entity.ClassType.ToInt();

                int intnum    = 0;
                var dbContext = new DAL.BaseDAL(CTMSContext);
                using (var db = dbContext.DbEntities())
                {
                    //using (var trans = db.Database.BeginTransaction())
                    //{
                    //    try
                    //    {
                    //        if (classType == 1)
                    //            dbContext.Delete(expressionPageFindByClassId);
                    //        dbContext.Delete(expressionClassFind);
                    //        intnum = db.SaveChanges();
                    //        trans.Commit();
                    //    }
                    //    catch (Exception)
                    //    {
                    //        trans.Rollback();
                    //    }
                    //    return intnum;
                    //}
                    db.Orm.Transaction(() =>
                    {
                        if (classType == 1)
                        {
                            dbContext.Delete(expressionPageFindByClassId);
                        }
                        dbContext.Delete(expressionClassFind);
                        intnum = db.SaveChanges();
                    });
                    return(intnum);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 3
0
        public int DeleteAccountAll(int systemId, string companyId, string memberId)
        {
            try
            {
                var entity = GetAccount(systemId, companyId, memberId);
                if (entity == null)
                {
                    throw new Exception("会员ID不存在!");
                }

                var expressionAddress = ExtLinq.True <Member_Address>();
                expressionAddress = expressionAddress.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.MemberID == memberId);
                var expressionInvoice = ExtLinq.True <Member_Invoice>();
                expressionInvoice = expressionInvoice.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.MemberID == memberId);

                int intnum    = 0;
                var dbContext = new DAL.BaseDAL(CTMSContext);
                using (var db = dbContext.DbEntities())
                {
                    //using (var trans = db.Database.BeginTransaction())
                    //{
                    //    try
                    //    {
                    //        dbContext.Delete(expressionAddress);
                    //        dbContext.Delete(expressionInvoice);
                    //        db.Set<Member_Account>().Remove(entity);
                    //        intnum = db.SaveChanges();
                    //        trans.Commit();
                    //    }
                    //    catch (Exception)
                    //    {
                    //        trans.Rollback();
                    //    }
                    //    return intnum;
                    //}

                    db.Orm.Transaction(() =>
                    {
                        dbContext.Delete(expressionAddress);
                        dbContext.Delete(expressionInvoice);
                        db.Set <Member_Account>().Remove(entity);
                        intnum = db.SaveChanges();
                    });
                    return(intnum);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 4
0
        public bool DeleteAdvertisement(int systemId, string companyId, string advertisementId)
        {
            try
            {
                var expressionAdvertisement = ExtLinq.True <Extend_Advertisement>();
                expressionAdvertisement = expressionAdvertisement.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.AdvertisementID == advertisementId);
                var expressionAdvertisementDetails = ExtLinq.True <Extend_AdvertisementDetails>();
                expressionAdvertisementDetails = expressionAdvertisementDetails.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.AdvertisementID == advertisementId);

                int intnum    = 0;
                var dbContext = new DAL.BaseDAL(CTMSContext);
                using (var db = dbContext.DbEntities())
                {
                    //using (var trans = db.Database.BeginTransaction())
                    //{
                    //    try
                    //    {
                    //        dbContext.Delete(expressionAdvertisement);
                    //        dbContext.Delete(expressionAdvertisementDetails);
                    //        intnum = db.SaveChanges();
                    //        trans.Commit();
                    //    }
                    //    catch (Exception)
                    //    {
                    //        trans.Rollback();
                    //    }
                    //    return intnum > 0;
                    //}

                    db.Orm.Transaction(() =>
                    {
                        dbContext.Delete(expressionAdvertisement);
                        dbContext.Delete(expressionAdvertisementDetails);
                        intnum = db.SaveChanges();
                    });
                    return(intnum > 0);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 2.0 删除方法1 删除给定的对象
 /// </summary>
 /// <param name="model"></param>
 /// <param name="IsSoftDel">是否软删除[*如果是软删除 则自动保存*]</param>
 /// <param name="Pro">软删除 要修改的删除标志字段</param>
 /// <param name="DelTag">软删除 删除标志值</param>
 /// <returns>如果非软删除则永远返回true 可以忽略</returns>
 public void Delete(T model, bool IsSoftDel, string Pro = "IsDelte", bool DelTag = true)
 {
     idal.Delete(model, IsSoftDel, Pro, DelTag);
 }
Exemplo n.º 6
0
        public bool UpdateAdvertisement(Extend_Advertisement entity, List <Extend_AdvertisementDetails> lists)
        {
            try
            {
                var    advertisementDetails = PrimaryKeyHelper.PrimaryKeyType.ExtendAdvertisementDetails;
                var    version         = PrimaryKeyHelper.PrimaryKeyLen.V1;
                int    systemId        = entity.SystemID;
                string companyId       = entity.CompanyID;
                string advertisementId = entity.AdvertisementID;
                entity.Sort       = entity.Sort.ToInt();
                entity.State      = entity.State.ToBool();
                entity.CreateDate = DateTime.Now;

                if (lists == null)
                {
                    throw new Exception("广告列表不能为空!");
                }
                List <Extend_AdvertisementDetails> details = new List <Extend_AdvertisementDetails>();
                foreach (var m in lists)
                {
                    string advertisementDetailsId = PrimaryKeyHelper.MakePrimaryKey(advertisementDetails, version);
                    m.SystemID        = entity.SystemID;
                    m.CompanyID       = entity.CompanyID;
                    m.DetailsID       = advertisementDetailsId;
                    m.AdvertisementID = advertisementId;
                    m.Sort            = m.Sort.ToInt();
                    m.State           = m.State.ToBool();
                    m.CreateDate      = DateTime.Now;
                    details.Add(m);
                }
                var expression = ExtLinq.True <Extend_AdvertisementDetails>();
                expression = expression.And(m => m.SystemID == systemId && m.CompanyID == companyId && m.AdvertisementID == advertisementId);

                int intnum    = 0;
                var dbContext = new DAL.BaseDAL(CTMSContext);
                using (var db = dbContext.DbEntities())
                {
                    //using (var trans = db.Database.BeginTransaction())
                    //{
                    //    try
                    //    {
                    //        dbContext.Update(entity);
                    //        dbContext.Delete(expression);
                    //        dbContext.Add(details);
                    //        intnum = db.SaveChanges();
                    //        trans.Commit();
                    //    }
                    //    catch (Exception)
                    //    {
                    //        trans.Rollback();
                    //    }
                    //    return intnum > 0;
                    //}
                    db.Orm.Transaction(() =>
                    {
                        dbContext.Update(entity);
                        dbContext.Delete(expression);
                        dbContext.Add(details);
                        intnum = db.SaveChanges();
                    });
                    return(intnum > 0);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }